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 |
终于ac了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator