HDU 2000 ASCII码排序
很简单,要注意的是读入字符的时候,要考虑空格、换行、回车等字符
#include <stdio.h>
void switch_a(char &a, char &b)
{
char tmp;
tmp = a;
a = b;
b = tmp;
}
void main()
{
char a,b,c,e;
char str[4];
while(scanf("%c%c%c%c",&a,&b,&c,&e)!= EOF)//虽然只输入三个字符,但是要注意回车也要读进来
{
if(a > b)
switch_a(a,b);
if(b > c)
switch_a(c,b);
if(a > b)
switch_a(a,b);
printf("%c %c %c\n",a,b,c);
}
}