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