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;
}

posted on 2011-04-28 11:02  more think, more gains  阅读(142)  评论(0编辑  收藏  举报

导航