Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求助 为何WA?

Posted by zhangxiang0509 at 2007-11-25 20:40:48 on Problem 2291
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator