Median
#include <stdio.h> #include <stdlib.h> #include <math.h> #define MAXSIZE 1000 int comp_inc(const void *first, const void *second); int main() { int Median_ind_1; int Median_ind_2; int n; scanf("%d", &n); int i; int seq[MAXSIZE]; for(i=0; i<n; ++i) scanf("%d", &seq[i]); qsort(seq, n, sizeof(seq[0]), comp_inc); for(i=0; i<n; ++i) { if(i!=0) printf(" "); printf("%d", seq[i]); } printf("\n"); Median_ind_1=ceil(n/2); int temp=n-1; Median_ind_2=((temp-1)/2)+1; printf("Median_ind_1=%d; Median=%d\n", Median_ind_1, seq[Median_ind_1]); printf("Median_ind_2=%d; Median=%d\n", Median_ind_2, seq[Median_ind_2]); return 0; } int comp_inc(const void *first, const void *second) { return *(int *)first-*(int *)second; }