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 |
Re:为什么WA?????????不理解In Reply To:为什么WA?????????不理解 Posted by:bootshl at 2008-07-31 16:37:30 > #include <stdio.h> > #include <stdlib.h> > > int cmp(const void* e1, const void* e2); > > int main(void) > { > int n, a[1001], i, count; > double sum, ave[101]; > count = 0; > while (scanf("%d", &n) == 1 && n) { > for (i = 0; i < n; i++) > scanf("%d", a + i); > qsort(a, n, sizeof(int), cmp); > sum = 0; > for (i = 1; i < n-1; i++) > sum += a[i]; > ave[count++] = sum/(n - 2); > } > for (i = 0; i < count; i++) > printf("%.0lf\n", ave[i]); > return 0; > } > > int cmp(const void* e1, const void* e2) > { > return (*(int*)e1) - (*(int*)e2); > } 为什么把ave[]改成int类型就过呢???double为什么不可以? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator