#include<stdio.h> /*void reverse(int a,int b) { int temp; temp=a; a=b; b=temp; }*/ int main() { int n; int a[100]; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } int max=1,min=1; for(int i=1;i<=n;i++) { if(a[i]>a[max])max=i; if(a[i]<a[min])min=i; } //reverse(a[1],a[min]); //reverse(a[n],a[max]); int temp; temp=a[1]; a[1]=a[min]; a[min]=temp; temp=a[n]; a[n]=a[max]; a[max]=temp; for(int i=1;i<n;i++) { printf("%d ",a[i]); } printf("%d\n",a[n]); } return 0; } |
Double click to view unformatted code.