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

daima

Posted by 2012xie at 2012-11-02 19:17:22 on Problem 1503
#include<stdio.h>
#include<string.h>
int main()
{
    char c[1000]={0};
    int b[1000]={0};
    int i,j,flag,n;
    while(scanf("%s",c)!=EOF)
    {
        n=strlen(c);
        if(n==1&&c[0]=='0')break;
        for(i=n-1,j=0;i>=0;i--)
        {
            b[j]+=c[i]-'0';
            //printf("%d:   %d\n",j,b[j]);
            j++;
        }
    }
    for(i=0;i<1000;i++)
    if(b[i]>9)
    {
        b[i+1]+=b[i]/10;
        b[i]=b[i]%10;
    }
   // printf("**************\n");
    flag=0;
    for(i=999;i>=0;i--)
    {
        if(flag||b[i]!=0)
        {
            printf("%d",b[i]);
            flag=1;
        }
        if(!flag&&i==0)
        printf("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