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 |
求助 为何WA?#include <stdio.h> #include <stdlib.h> int main() { int n; int w, i, j, x = 0; int num, p, q; int length[1000]; int array[1000]; int max; scanf("%d", &n); for (w = 0; w < n; w++) { scanf("%d", &num); for (p = 0; p < num; p++) { scanf("%d", &length[p]); } for (i = 0; i < num; i++) { for (j = i + 1; j < num + 1; j++) { int temp; if (length[j] < length[i]) { temp = length[i]; length[i]= length[j]; length[j] = temp; } } } max = length[0] * num; for (p = 0; p < 1; p++) { for (q = p + 1; q < num + 1; q++) { if (max < length[q] * (num - q)) max = length[q] * (num - q); array[x] = max; } } x++; } for (x = 0; x < n; x++) { printf("%d\n", array[x]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator