| ||||||||||
| 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 | |||||||||
用字符串做,附代码#include <iostream>
using namespace std;
int main()
{
int i,sum,b,n;
char a[2000];
while(1)
{
scanf("%s",a);
if(strcmp(a,"0")==0)
break;
n=strlen(a);
sum=0;
for(i=0;i<n;i++)
sum+=a[i]-'0';
b=sum%9;
if(b==0)
b=9;
cout<<b<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator