Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么wa?测试数据都通过了。哪位大哥帮帮小妹,万谢啊!!

Posted by lucy_whu at 2007-12-26 14:25:20 on Problem 1503
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator