Home > Back-end >  A pointer to a small problem
A pointer to a small problem

Time:06-05


This is the code, but the output of two sets of data, output all the answer to the first group,
Behind a sample, I hope my friends can help me, thank you!

This code, but the output is wrong,

#include
#include
#include
Struct sb
{
Int num1 [3].
Int num2 [3].
} hx [3].
Int main ()
{
Int the cas (int a [], int [] b);
Int n, I, k, * u * o;
Int the SBS;
The scanf (" % d ", & amp; N);
for(i=0; I & lt; n; I++)
{
For (k=0; K & lt; 3; K++)
{
The scanf (" % d % d ", & amp; Hx [I] num1 [k], & amp; Hx [I] num2 [k]);
}
U=hx [0]. Num1;
O=hx [0]. Num2;
The SBS=cas (u, o);
Printf (" % d \ n ", the SBS);
}
return 0;
}
Int the cas (int a [], int [] b)
{
Int I, * j * h;
J=a; H=b;
for(i=0; I & lt; 1000; I++)
{
If ((I * j * h==%) & amp; & (I % * (j + 1)==* (h + 1)) & amp; & (I % * (j + 2)==* (h + 2)))
{
break;
}
}
Return the I;
}


Huaian folklore with a story, "han xin point soldier", the second a idiom "han xin point soldier, the more the better," han xin with 1500 soldiers in battle, killed five centuries, stood a row of three people, more than 2 people; Stood a row of 5 people, more than four people; Station 7, 6 people, the more the han xin right number: 1049, if I give you some conditions, could you help me to meet the conditions of the smallest positive integer?
, of course, the problem is simple, give you each group of data line has three Numbers, Numbers in each row of the first number is the divisor d, the second number is the remainder m, then please work out a minimal positive integer n (n & lt; 1000000), the n can satisfy the three lines of figures at the same time n/d==x... M.

Input

The first line is the number of sets of data nCase (n<=5), the following three ncase lines, each three lines is a set of data that is to give you three sets of data,

The Output

For each group of input, output a line, is obtained by the least positive integer,

The Sample Input
2
3 2
5 4
7 (6)
9 2
7 3
6 5
The Sample Output
104
101

CodePudding user response:

The same topic is what's the problem? Is not a pointer to a small problem, should be a logical problem ~

CodePudding user response:

U=hx [0]. Num1;
O=hx [0]. Num2;

Should be the problem of two rows
Every time is the processing of 0, it should be handling of I
U=hx [I] num1;
O=hx [I] num2;

CodePudding user response:

Fun
reference 2 floor response:
u=hx [0]. Num1.
O=hx [0]. Num2;

Should be the problem of two rows
Every time is the processing of 0, it should be handling of I
U=hx [I] num1;
O=hx [I] num2;

Well yes,,,,,,,,,,,,,,,, well, yes

CodePudding user response:

Fun
reference 2 floor response:
u=hx [0]. Num1.
O=hx [0]. Num2;

Should be the problem of two rows
Every time is the processing of 0, it should be handling of I
U=hx [I] num1;
O=hx [I] num2;

Changed to this
#include
Struct sb
{
Int num1 [3].
Int num2 [3].
} hx [5].
Int main ()
{
Int the cas (int a [], int [] b);
Int n, I, k, * u * o;
Int the SBS;
The scanf (" % d ", & amp; N);
If (n & lt;
=5){
While (n -)
{
For (k=0; K & lt; 3; K++)
{
The scanf (" % d % d ", & amp; Hx [I] num1 [k], & amp; Hx [I] num2 [k]);
}
U=hx [I] num1;
O=hx [I] num2;
The SBS=cas (u, o);
Printf (" % d \ n ", the SBS);
}
}
return 0;
}
Int the cas (int a [], int [] b)
{
Int I, * j * h;
J=a; H=b;
for(i=0; I & lt; 1000; I++)
{
If ((I * j * h==%) & amp; & (I % * (j + 1)==* (h + 1)) & amp; & (I % * (j + 2)==* (h + 2)))
{
Return the I;
break;
}
}
}


Results are right, but is the submission wrong

CodePudding user response:

The
reference 1/f, confident boy reply:
what is the title of the same problem? Not a pointer to a small problem, should be a logical problem ~

To this

#include
Struct sb
{
Int num1 [3].
Int num2 [3].
} hx [5].
Int main ()
{
Int the cas (int a [], int [] b);
Int n, I, k, * u * o;
Int the SBS;
The scanf (" % d ", & amp; N);
If (n & lt;
=5){
While (n -)
{
For (k=0; K & lt; 3; K++)
{
The scanf (" % d % d ", & amp; Hx [I] num1 [k], & amp; Hx [I] num2 [k]);
}
U=hx [I] num1;
O=hx [I] num2;
The SBS=cas (u, o);
Printf (" % d \ n ", the SBS);
}
}
return 0;
}
Int the cas (int a [], int [] b)
{
Int I, * j * h;
J=a; H=b;
for(i=0; I & lt; 1000; I++)
{
If ((I * j * h==%) & amp; & (I % * (j + 1)==* (h + 1)) & amp; & (I % * (j + 2)==* (h + 2)))
{
Return the I;
break;
}
}
}

The result, but once you have submitted the wrong

CodePudding user response:

Didn't see this topic and "little pointer" have anything to do

There are two kinds of wrong words is

The input and output format problems
Subject requirement is one-time input, then one-time output, not input and output,
The calculation results are cached, an output

The second algorithm itself
To han xin point soldier the original may be in 3, 5, 7, The number of the most qualified will not exceed 105
But, you this problem is obviously not 3, 5, 7,
A second group of 9 July 6 is the smallest scope of 126
Test data may have a bigger case, you write dead I the upper limit of 1000, would probably be enough

And you for (I=0; I & lt; 1000; I++) here I start from 0, if more than 3 digits number more than 0, 0, 5 more than the number 0, 7 are you going to tell the system that no one?
By default. No one should be the living is also a few fart, this time it's like 105

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related