Home > Back-end >  C language errors, want to for a long time, for years, error correction
C language errors, want to for a long time, for years, error correction

Time:10-14

Want to write in the bubbling the sorting, feel this output is a bit puzzling,, see?




This is the source:
#include
Int main ()
{
int i,j;
Char a [3], temp.
While (the scanf (" % % % c c c ", & amp; A [0], & amp; A [1], & amp; A [2]).=(EOF)
{
for(i=0; i<3-1; I++)
{
for(j=0; j<3 - I - 1; J++)
{
If (a [j] & gt; A [m + 1])
{
Temp=a, [j].
A [j]=a, a + 1 bonus to [j].
A=\ [j + 1];
}
}
}
Printf (" % % % c c c \ n ", a [0], a [1], a [2]).
}
return 0;
}

CodePudding user response:

To think of it, add a getchar (), if anyone who can explain it getchar (), the function, points will give you thanks ~

CodePudding user response:

Getchar () is to receive a characters, including Spaces, press enter

CodePudding user response:

While (the scanf (" % % % c c c ", & amp; A [0], & amp; A [1], & amp; A [2]).=(EOF), and then there were a \ n
in the buffer

CodePudding user response:

reference 1st floor Dreamypurple response:
, add a getchar (), if anyone who can explain it getchar (), the function, points will give you thanks ~

% c is will match '\ n' is a newline, so will appear the phenomenon of the building Lord
  • Related