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 |
please tell me which place is wrong#include<stdio.h> void main(){ long a[7],i,sum,p,k,sum1,j; for(k=1;;k++){ sum=0; for(i=1;i<=6;i++){ scanf("%d",&a[i]); sum+=i*a[i]; } if(sum==0) break; p=sum/2; sum1=0; if(sum!=p*2) printf("Collection #%d:\nCan't be divided.\n",k); else { for(i=1;i<6;i++){ for(j=1;j<=a[i];j++){ sum1+=i; if(sum1>=p)break; } if(sum1>=p)break; } if(sum1==p)printf("Collection #%d:\nCan be divided.\n",k); else printf("Collection #%d:\nCan't be divided.\n",k); } printf("\n"); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator