#include<stdio.h> #include<stdlib.h> int main(){ int n,temp; scanf("%d", &n); int* array = (int*)malloc(sizeof(int)*n); for(int i =0;i<n;++i){ scanf("%d", array+i); } for(int i =1;i<n-1;++i){ if(array[i] < array[0]){ temp = array[i]; array[i] = array[0]; array[0] = temp; } else if(array[i] > array[n-1]){ temp = array[i]; array[i] = array[n-1]; array[n-q] = temp; } } for(int i = 0;i<n-1;++i){ printf("%d ", array[i]); } printf("%d", array[n-1]); free(array); return 0; } /* Main.c: In function 'main': Main.c:19:15: error: 'q' undeclared (first use in this function) array[n-q] = temp; ^ Main.c:19:15: note: each undeclared identifier is reported only once for each function it appears in */ |
Double click to view unformatted code.