题目地址:https://vjudge.net/problem/hdu-2000
题目分析:利用输入作为判断条件输入三个字符,利用冒泡算法进行排序即可。
代码:#include
using namespace std;
int main()
{
char p[3], k;
while (cin >> p[0] >> p[1] >> p[2])
{
for (int a = 0; a < 2; a++)
{
int w = 1;
for (int b = 0; b < 2 - a; b++)
if (p[b] > p[b + 1])
{
k = p[b];
p[b] = p[b + 1];
p[b + 1] = k;
w = 0;
}
if (w) break;
}
cout << p[0] << " " << p[1] << " " << p[2] << endl;
}
return 0;
system(“pause”);
}
6.acm
最新推荐文章于 2020-11-28 18:33:12 发布
