输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
AC代码:
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n; getchar();
char x[4];
while (gets(x),n--)
{
int i,j;
for (i = 1; i < 3; i++)
{
for (j = 0; j <3-i; j++)
{
char tmp;
if (x[j] > x[j + 1])
{
tmp = x[j+1];
x[j + 1] = x[j];
x[j] = tmp;
}
}
}
cout << x[0] << " " << x[1] << " " << x[2] << endl;
}
//system("pause");
return 0;
}