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

终于ac了

Posted by crazyyangdan at 2011-05-28 15:25:04 on Problem 1519
#include<iostream>
#include<string>
using namespace std;
int main()
{ 
  char a[2000];
  int b[2000];
  int n;
  
  while(cin>>a&&a[0]!='0')
  { int sum=0;
     n=strlen(a);
     for(int i=0;i<n;i++)
     {b[i]=a[i]-48;
      sum+=b[i];
     }
     int c,d,e,f,g;
     c=sum/10000;
     d=sum%10000/1000;
     e=sum%1000/100;
     f=sum%100/10;
     g=sum%10;
     sum=c+d+e+f+g;
    if(sum<10) cout<<sum<<endl;   
     else   {sum=sum%10+sum/10; cout<<sum<<endl;}
  }                  
  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