标签:hdu
4 2 1 3 4 5 5 4 3 2 1 0
1 2 3 4 1 4 3 2 5
#include <iostream> using namespace std; int main() { int n; while (cin >> n && n) { int a[110], t; for (int i=0; i<n; i++) cin >> a[i]; int flag = a[0]; int min=a[0]; for (int i=0; i<n; i++) { if (a[i] < min) { min = a[i]; } } a[0] = min; for (int i=1; i<n; i++) { if (a[i] == min) { a[i] = flag; break; } } cout << a[0]; if ( n > 1 ) { for (int i=1; i<n; i++) cout << " " << a[i]; } cout << endl; } return 0; }
标签:hdu
原文地址:http://blog.csdn.net/xiaotan1314/article/details/45971653