| ||||||||||
| 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>
using namespace std;
int a[100],b[100],n;
char c[110];
int c2b()
{
int tag=n-1,cn=0,sum=0,exp=1,flag=0;
while(tag>=0)
{
sum+=exp*(c[tag]-'0');
exp*=10;
cn++;
if(cn==8)
{
b[flag++]=sum;
sum=0;
exp=1;
cn=0;
}
tag--;
}
b[flag++]=sum;
return flag;
}
int main()
{
int i,j,m;
memset(a,0,sizeof(a));
while(1)
{
cin>>c;
if(c[0]=='0')break;
n=strlen(c);
m=c2b();
for(j=0;j<=m;j++)
{
a[j]+=b[j];
if(a[j]>=100000000)
{
a[j+1]+=a[j]/100000000;
a[j]%=100000000;
}
}
}
for(i=100;;i--)
if(a[i]!=0)break;
printf("%d",a[i]);
i--;
for(;i>=0;i--)
printf("%08d",a[i]);
printf("\n");
system("pause");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator