#include <stdio.h> int main() { int n,i,max=min=0,t; int a[10]; scanf("%d",&n); for(i=0;i<n;++i) scanf("%d",&a[i]); for(i=0;i<n;++i) { if(a[min]>a[i]) min=i; if(a[max]<a[i]) max=i; } temp=a[0];a[0]=a[min];a[min]=temp; temp=a[n-1];a[n-1]=a[max];a[max]=temp; for(i=0;i<n-1;++i) printf("%d ",a[i]); printf("%d",a[n-1]); } /* Main.c: In function 'main': Main.c:4:14: error: 'min' undeclared (first use in this function) int n,i,max=min=0,t; ^ Main.c:4:14: note: each undeclared identifier is reported only once for each function it appears in Main.c:15:4: error: 'temp' undeclared (first use in this function) temp=a[0];a[0]=a[min];a[min]=temp; ^ Main.c:4:20: warning: unused variable 't' [-Wunused-variable] int n,i,max=min=0,t; ^ */ |
Double click to view unformatted code.