HDOJ 2000 ASCII码排序

来源:互联网 发布:淘宝外贸店推荐 编辑:程序博客网 时间:2024/06/05 17:53

ASCII码排序

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 85132    Accepted Submission(s): 35506


Problem Description
输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
 

Input
输入数据有多组,每组占一行,有三个字符组成,之间无空格。
 

Output
对于每组输入数据,输出一行,字符中间用一个空格分开。
 

Sample Input
qweasdzxc
 

Sample Output
e q wa d sc x z
 

Author
lcy
 

Source
C语言程序设计练习(一)
 

#include <stdio.h>int main (){    char a[3],temp;    while (scanf("%s",a)!=EOF)    {        for (int i=0; i<2; i++)            for (int j=i+1; j<3; j++)            {                if (a[i]>a[j])                {                    temp=a[i];                    a[i]=a[j];                    a[j]=temp;                }            }        for (int i=0; i<3; i++)        {            printf ("%c",a[i]);            if (i!=2)   printf (" ");        }        printf ("\n");    }    return 0;}

Run IDSubmit TimeJudge StatusPro.IDExe.TimeExe.MemoryCode Len.LanguageAuthor111055502014-07-20 17:28:45Accepted20000MS228K540 BC++Hidden Secret

0 0
原创粉丝点击