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

怎么会wrong answer呢?

Posted by 200531500035 at 2006-11-29 17:23:30 on Problem 1247
#include<stdio.h>

int main ()
{
        int flag,i,j,shead,srear,a[30]={0},num;
        scanf("%d",&num);
        while(num)
        {
                for(i=0;i<num;i++)
                scanf("%d",&a[i]);
                flag=1,shead=srear=0;
                while(shead<=srear)
                {
                        shead=srear=0;
                        for(i=0;i<flag;i++)
                        shead+=a[i];
                        for(j=num;j>=flag;j--)
                        srear+=a[j];
                        if(shead==srear)
                        {
                                 printf("Sam stops at position %d and Ella stops at position %d.\n",flag,flag+1);
                                 break;
                        }
                        flag++;
                        if(shead>srear)
                        {
                               printf("No equal partitioning.\n");
                               break;
                        }       
                }
                
                scanf("%d",&num);
        }
              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