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了n次

Posted by ganma at 2007-10-29 20:27:44 on Problem 1503
#include<iostream>
#include<string>
using namespace std;
int main()
{
 string longint;
  static int a[103]={0};
  int max=0;
 while(cin>>longint,longint!="0")
 {  
        int n=longint.length();
        for(int i=n-1,j=102;i>=0;i--,j--)
        {
                a[j]+=(int)longint[i]-48;
                if(a[j]>=10)
                {
                            a[j]=a[j]%10;
                            ++a[j-1];
                            if(a[j-1]==10)
                            {
                            a[j-1]=0;
                            ++a[j-2];
                            }
                }
        }
 }
 for(int i=0;i<104;i++)
{
    if(a[i]>0)
    { 
              for(int j=i;j<103;j++)
              cout<<a[j];
              cout<<endl;
              break;
    }
    else if(i==103)
    cout<<"0"<<endl;
 }
 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