| ||||||||||
| 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<iostream.h>
#include<string.h>
void main()
{
char a[101],sum[103];
char *s=sum,*d;
int i,j,p,l,t,flag=0;
for(i=0;i<103;i++)
sum[i]='0';
for(i=1;i<=100;i++){
cin>>a;
p=0;
l=strlen(a);
for(i=0;i<l;i++)
p+=a[i]-'0';
if(p==0)break;
for(i=102,j=l-1;j>=0;i--,j--){
t=sum[i]-'0'+a[j]-'0';
if(t>9){
sum[i]=t-10+'0';
sum[i-1]=sum[i-1]-'0'+1+'0';
}
else sum[i]=t+'0';
}
}
for(s=sum;;s++)
if(*s!='0')break;
for(d=s;d<(sum+103);d++)
cout<<*d;
cout<<endl;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator