After the Problem description is entered, the three characters are output in ascending order of the ASCII code of each character. Input
There are multiple groups of input data, each group occupies one rowIt consists of three characters and has no space between them.
// Filter the carriage return with % * COutput
Output one row of input data for each group, Separated by a space.
Printf ("... \ n ");Sample inputqwe ASD zxc sample outpute Q wa d SC x zcode1: # include <stdio. h> int main () {char a, B, c, TMP; while (scanf ("% C % * C", & A, & B, & C )! = EOF )//
Use "% * C" (null character, character not stored) to filter out the carriage return{If (A> B) TMP = A, A = B, B = TMP; // comma expression, concise if (a> C) TMP = A, A = C, C = TMP; If (B> C) TMP = B, B = C, C = TMP; printf ("% C \ n", A, B, c);} return 0;} code2:
# Include <stdio. h>
Int main ()
{
Char A, B, C, TMP;
While (A = getchar ())! = EOF)
{
B = getchar ();
C = getchar ();
Getchar (); // use getchar () to filter out the carriage return after entering C
If (A> B)
{
TMP =;
A = B;
B = TMP;
}
If (A> C)
{
TMP =;
A = C;
C = TMP;
}
If (B> C)
{
TMP = B;
B = C;
C = TMP;
}
Printf ("% C \ n", A, B, C );
}
Return 0;
}
Use % * C to filter out carriage return and sort by ASCII code