ACM训练

题目地址:https://vjudge.net/problem/hdu-2000
题目分析:利用输入字符数组做循环条件,在循环结构中对字符数组进行排序处理,然后再按照要求输出即可。
#include
using namespace std;
int main()
{
char a[3];
while (cin>>a[0]>>a[1]>>a[2])
{
for (int n = 0; n < 2; n++)
{
int x = 1;
for (int i = 0; i < 2; i++)
{
if (a[i] > a[i + 1])
{
char o = a[i];
a[i] = a[i + 1];
a[i + 1] = o;
x = 0;
}
}
if (x)break;
}
cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

}

你可能感兴趣的:(ACM训练)