#include <iostream> #include <algorithm> #include <cmath> #include <cstring> #define maxn 25 #define INF 0x3f3f3f3f using namespace std; int a[maxn]; int main() { int n; while (cin >> n) { // 注意 while 处理多个 case for(int i=0;i<n;i++) { cin>>a[i]; } int maxx = -INF,minn = INF; int p1,p2; for(int i=0;i<n;i++) { if(a[i]>maxx) { maxx = a[i]; p1 = i; } if(a[i]<minn) { minn = a[i]; p2 = i; } } swap(a[p1],a[p2]); for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl; } } // 64 位输出请用 printf("%lld")