| ||||||||||
| 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 | |||||||||
怎么会wrong answer呢?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator