ACM HDU 11 2016 数据的交换输出

#include 
using namespace std;
int main()
{
	int n;
	int Lu[102];
	while (cin >> n && n)
	{
		for (int i = 1; i <= n; i++)
			cin >> Lu[i];
		int temp;
		for (int i = 1; i <= n; i++)
		{
			int x = 0;
			for (int j = 1; j <= n; j++)
				if (Lu[i] <= Lu[j])
					x++;
			if (x == n)
			{
				temp = Lu[i];
				Lu[i] = Lu[1];
				Lu[1] = temp;
				break;
			}
		}
		cout << Lu[1];
		for (int i = 2; i <= n; i++)
			cout << ' ' << Lu[i];
		cout << endl;
	}
	return 0;
}

你可能感兴趣的:(ACM HDU 11 2016 数据的交换输出)