| ||||||||||
| 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 | |||||||||
菜鸟求救考虑了各种数据,包括以0开头的数据。各种变态数据都测试成功了,但就是wrong answer.为什么?
#include<stdio.h>
#include<string.h>
void main()
{
char a[102],b[103];
int i,j,l1,l,k;
for(i=0;i<103;i++)
b[i]='0';
for(i=0;i<101;i++)
{
scanf("%s",a);
if(a[0]=='0'&&a[1]=='\0')
break;
l1=strlen(a);
l=102;
for(j=l1-1;j>=0;j--,l--)
{
b[l]+=a[j]-'0';
if(b[l]>'9')
{
b[l]-=10;
b[l-1]++;
}
}
}
i=0;
while(b[i]=='0')i++;
for(k=i;k<=102;k++)
printf("%c",b[k]);
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator