#include <stdafx.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ void swap(int *a,int *b) {int c; c=*a; *a=*b; *b=c; } int main(int argc, char *argv[]) { int lk[11],n,i,a,b,z,x; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&lk[i]); for(i=0,a=lk[0];i<n-1;i++)//max { if(a<lk[i]) {a=lk[i]; z=i; } } for(i=0,b=lk[0];i<n-1;i++)//min { if(b>lk[i]) {b=lk[i]; x=i; } } swap(&lk[z],&lk[n-1]); swap(&lk[x],&lk[0]); for(i=0;i<n;i++) printf("%d\t",lk[i]); return 0; } /* Main.c:1:20: fatal error: stdafx.h: No such file or directory #include <stdafx.h> ^ compilation terminated. */ |
Double click to view unformatted code.