ASCII码排序
Time limit 1000 ms
Memory limit 32768 kB
OS Windows
输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
Input
输入数据有多组,每组占一行,有三个字符组成,之间无空格。
Output
对于每组输入数据,输出一行,字符中间用一个空格分开。
Sample Input
qwe
asd
zxc
Sample Output
e q w
a d s
c x z
问题链接:https://vjudge.net/problem/hdu-2000
问题简述:输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
问题分析:用asc||码的大小比较字符大小。
AC通过的C语言程序如下:
#include<iostream>
using namespace std;
int main()
{
char a, b, c;
while (cin >> a >> b >> c)
{
if (a > b)
{
char temp;
temp = b;
b = a;
a = temp;
}
if (a > c)
{
char temp;
temp = c;
c = a;
a = temp;
}
if (b > c)
{
char temp;
temp = c;
c = b;
b = temp;
}
cout << a << " " << b << " " << c << endl;
}
return 0;
}