The greatest common divisor int main ()//o
{
Int a, b, min, I, x;
Printf (" input two Numbers: \ n ");
The scanf (" % d, % d ", & amp; A, & amp; B);
for(i=1; i<=min; I++)
{
If (a % I==0 & amp; & B % I==0)
X=I;
}
Output greatest common divisor printf (" % d ", x);
//since the childhood screening
}
Beg from small (1) to (min), and with the above procedures have differences, or correct the following program,
#include
The greatest common divisor int main ()//o
{
Int a, b, min, I;
Printf (" input two Numbers: \ n ");
The scanf (" % d, % d ", & amp; A, & amp; B);
for(i=1; i<=min; I++)
{
If (a % I==0 & amp; & B % I==0)
continue;
}
Output greatest common divisor printf (" % d ", I - 1);
//since the childhood screening
}
CodePudding user response:
Do you want you to do anything for youCodePudding user response:
Min variable is not initialized directly use of the building Lord, there will be a problemCodePudding user response:
Min=(a CodePudding user response: I wrote a code (it's a pity that is wrong), as follows:#include
Int main ()
{
Int a, b, min, I;
The scanf (" % d, % d ", & amp; A, & amp; B);
Min=(afor(i=1; i<=min; I++)
{
If (a % I==0 & amp; & B % I==0)
continue;
}
Output greatest common divisor printf (" % d ", I - 1);
}
The teacher found that after changed to
#include
Int main ()
{
Int a, b, min, x, I;
The scanf (" % d, % d ", & amp; A, & amp; B);
Min=(afor(i=1; i<=min; I++)
{
If (a % I==0 & amp; & B % I==0)
X=I;
}
Output greatest common divisor printf (" % d ", x);
}
Then, the teacher asked me in another way from small to large, screening of greatest common divisor
CodePudding user response:
The original poster wrote a program (wrong), the teacher found that after adding a variable make the program is correct, then the teacher asked the building use another method revision program,The original poster write programs:
#include
Int main ()
{
Int a, b, min, I;
The scanf (" % d, % d ", & amp; A, & amp; B);
Min=(afor(i=1; i<=min; I++)
{
If (a % I==0 & amp; & B % I==0)
continue;
}
Output greatest common divisor printf (" % d ", I - 1);
}
The teacher write programs:
#include
Int main ()
{
Int a, b, min, x, I;
The scanf (" % d, % d ", & amp; A, & amp; B);
Min=(afor(i=1; i<=min; I++)
{
If (a % I==0 & amp; & B % I==0)
X=I;
}
Output greatest common divisor printf (" % d ", x);
}