Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用qsort加int就能过!--第一次试着用qsort!#include <stdio.h> #include <stdlib.h> int cmp(int *a, int *b){ return *a - *b; } int main(){ int n, i; int abc[10000]; scanf("%d", &n); for(i = 0; i < n; i++){ scanf("%d", abc+i); } qsort((void *)abc, n, sizeof(int),(int (*)(const void *a, const void *b))(cmp)); printf("%d\n",abc[n / 2]); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator