4 ASCII码排序

来源:互联网 发布:如何在网络上找外教 编辑:程序博客网 时间:2024/06/14 00:33

ASCII码排序

时间限制:3000 ms  |  内存限制:65535 KB
难度:2
描述
输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符。
输入
第一行输入一个数N,表示有N组测试数据。后面的N行输入多组数据,每组输入数据都是占一行,有三个字符组成,之间无空格。
输出
对于每组输入数据,输出一行,字符中间用一个空格分开。
样例输入
2qweasd
样例输出
e q wa d s


#include<stdio.h>

#include <stdlib.h>


int main()
{
    int num=0,top=0,down=0;
    scanf("%d",&num);




    char asc[128]={'0'};
    char temp,out;
    getchar();
    while(num--)
    {
        top=0;
        out=97;
        temp=getchar();
        while (top<127&temp!='\n')
        {
        asc[top]=temp;
        temp=getchar();
        top++;
        }
        while(out<='z')
        {
            down=0;
            while(down<=top)
            {


            if(asc[down]==char(out))
                {
                    printf("%c ",asc[down]);
                    asc[down]='0';
                }
            down++;
            }
            out++;
        }


        printf("\n");


    }


    return 0;
}
0 0
原创粉丝点击