#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> int a[20]; int main(){ int n; int t; int flag; scanf("%d",&t); for(int i=0;i<t;i++){ scanf("%d",&a[i]); } int min=0; for(int i=0;i<t;i++){ if(a[min]>a[i]){ min=i; } } int temp; temp=a[0]; a[0]=a[min]; a[min]=temp; int max=0; for(int i=0;i<t;i++){ if(a[max]<a[i]){ max=i; } } temp=a[t-1]; a[t-1]=a[max]; a[max]=temp; for(int i=0;i<t;i++){ if(i==0){ printf("%d",a[i]); } else printf(" %d",a[i]); } } |
Double click to view unformatted code.