#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:4:3: error: stray '\357' in program int n,temp; ^ Main.c:4:3: error: stray '\274' in program Main.c:4:3: error: stray '\214' in program Main.c:4:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'temp' int n,temp; ^ Main.c:4:11: error: 'temp' undeclared (first use in this function) Main.c:4:11: note: each undeclared identifier is reported only once for each function it appears in Main.c:5:16: error: 'n' undeclared (first use in this function) scanf("%d", &n); ^ Main.c:19:15: error: 'q' undeclared (first use in this function) array[n-q] = temp; ^ */ |
Double click to view unformatted code.