输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
#include<stdio.h>
int main()
{
char a,b,c,temp;
int input;
input=scanf("%c%c%c",&a,&b,&c);
while(input!=EOF)
{
if(a>b)
{
temp=a;
a=b;
b=temp;
}
if(a>c)
{
temp=a;
a=c;
c=temp;
}
if(b>c)
{
temp=b;
b=c;
c=temp;
}
printf("%c%c%c\n",a,b,c);
scanf("%c",&a);
input=scanf("%c%c%c",&a,&b,&c);
}
return 0;
}
输入:qwe 输出:eqw
asd ads
zxc cxz