POJ_2388

简单练手, 在没有接触ACM之前竟然不知道C中有qsort()函数, 哎, 说出来丢人, 主要用下qsort()就行了...

 

#include <stdio.h> #include <stdlib.h> #define MAX_COUNT 10000 int cmp(const void* a, const void* b) { return *(int*)a - *(int*)b; } int main() { int count; int cows[MAX_COUNT] = {0}; int i = 0; scanf("%d", &count); for(; i<count; i++) scanf("%d", &cows[i]); qsort(cows, count, sizeof(int), cmp); printf("%d/n", cows[count / 2]); return 0; } 

你可能感兴趣的:(c)