Home > Back-end >  devc
devc

Time:09-16

Division algorithm code appear problem, the input Numbers cannot out as a result, please have a look at
#include
Int main ()
{
Int x, y, t, a;
The scanf (" % d % d ", "\ n", & amp; X, & amp; Y);
If (x & lt; Y) {
A=x; X=y; Y=a;
}
T=x % y
While (t!=0) {
X=y; Y=t;
}

Printf (" % d \ n ", y);
}
The results
1 1

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The Process exited after 4.58 seconds with the return value of 3221225477
Please press any key to continue...

CodePudding user response:

The scanf (" % d % d ", "\ n", & amp; X, & amp; Y);===& gt;> The scanf (" % d % d ", & amp; X, & amp; Y);
There can be only one double quotation marks, comma and \ n are removed

CodePudding user response:

Only the first parameter is used to locate the scanf function of only the first two strings a prompt for the second parameter is the function of the input position

CodePudding user response:

Right: the scanf (" % d % d ", & amp; X, & amp; Y);

CodePudding user response:

1, the scanf statement is wrong, the first comma on either side of the not, input end without a result, after should be the cause,
2, t=x % y; <===remember add a semicolon.
3, the while loop, is infinite loop!

CodePudding user response:

have a semicolon didn't add

CodePudding user response:

reference 4 floor zlei_csdn response:
1, the scanf statement is wrong, don't, the first comma on either side of the input end without a result, after should be the cause of,
2, t=x % y; <===remember add a semicolon.
3, the while loop, is infinite loop!

Thank you bosses,

CodePudding user response:

The
reference 5 floor ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` response:
have a semicolon didn't add

thank you

CodePudding user response:

The
reference 3 floor Tryagain2006 response:
right: the scanf (" % d % d ", & amp; X, & amp; Y);

thank you

CodePudding user response:

Your input format is right, if you are "& amp; D, % d "that you input is 6, 5 this appearance, but also pay attention to English and Chinese comma is also not the same
  • Related