Problem description Input Three characters, the ASCII code of each character is printed in order from small to large to output these three characters.
Input data has more than one group, each of which consists of three characters and no spaces between them.
Output for each set of input data, one line is printed, and the characters are separated by a space.
Sample INPUTQWEASDZXC
Sample outpute q wa d sc x z below is the code:
#include <stdio.h> #include <stdlib.h> #include <string.h>int main () {char a,b,c,d,max,min;while ( scanf ("%c%c%c%c", &a,&b,&c,&d)!=eof)//Here to add four variables, because there is one to be used to absorb the carriage return {if (a>b) { max=a; Min=b;} Else{max=b;min=a;
The biggest difficulty of the problem is to consider the absorption of the carriage return, but I this method is more stupid, the following is the new method I learned!
#include <stdio.h>#include<stdlib.h>#include<string.h>intMain () {Chara,b,c,d,x,y,z; while(SCANF ("%c%c%c%c", &a,&b,&c,&d)! =EOF) {x=a<b?a:b; X=x<c?X:c; Z=a>b?a:b; Z=z>c?Z:c; Y=a+b+c-x-Z; printf ("%c%c%c\n", x, Y, z); }return 0;}
Improved, really simple a lot of, but the above is my own thought out, or very fulfilling sense! Hope to bring you help!
ASCII sort, hdu-2000