HUD-2000 简单排序(c++)

HUD-2000简单排序解法(c++)

//把字符串类型先强制转化为整型进行排序。

#include <iostream>
using namespace std;

int main()
{
	char x, y, z;
	while (cin >> x >> y >> z)
	{
		if (int(x) > int(y))
		{
			char temp = x;
			x = y;
			y = temp;
		}
		if (int(x) > int(z))
		{
			char temp = x;
			x = z;
			z = temp;
		}
		if (int(y) > int(z))
		{
			char temp = y;
			y = z;
			z = temp;
		}
		cout << x << " " << y << " " << z << endl;
	}

	
}

猜你喜欢

转载自blog.csdn.net/weixin_43655282/article/details/89044394