tangcong

ASCII码排序

#include<stdio.h>
int main( )
{
    char ch[10];
    while(scanf("%s",ch)!=EOF)
    {
    int a,b,c,temp;
    a=ch[0]-48;
    b=ch[1]-48;
    c=ch[2]-48;
    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",c+48,b+48,a+48);
    }
    return 0;
}

分类:

技术点:

相关文章: