Home > Back-end >  Beginner's a question...
Beginner's a question...

Time:10-11

#include
Void swap (int * p, int * q)
{
Int temp.
Temp=* p;
* p=* q;
* q=temp;
return;
}
Void exchange (int * x, int * y, int * z)
{
If (* x & lt; * y)
Swap (x, y);
If (* x & lt; * z)
Swap (x, z);
If (* y & lt; * z)
Swap (y, z);
return;

}
Int main (void)
{
Int a, b, c;
P1, int * * p2, p3;
The scanf (" % d, % d, % d ", & amp; A, & amp; B, & amp; C);
P1=& amp; a; The p2=& amp; b; P3=& amp; c;
Exchange (p1, p2, p3);
Printf (" % d, % d, % d \ n ", a, b, c);

return 0;
}

Why there are garbage output value

CodePudding user response:

Program will be a problem, it is recommended that the landlord to pay attention to the input format, pay attention to the comma, don't enter into Chinese comma.

Or under the scanf a print a, b, c, to ensure that the input is no problem, and then the positioning exchange if there is a problem,

CodePudding user response:

Program will be a problem, that is, the scanf function you write the scanf (" % d, % d, % d ", & amp; A, & amp; B, & amp; C); Are separated by commas, the input value with a comma, comma and want to use English,
  • Related