| ||||||||||
| 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 | |||||||||
why!高人半忙指点一下!我的代码为什么老ac不了?愤啊!!!
#include <iostream>
using namespace std;
int root (int n)
{ int a;
do
{ a=0;
while(n>0)
{
a+=n%10;
n=n/10;
}
n=a;
}while(n>=10);
return n;
}
int main()
{
int p;
while(1)
{
cin>>p;
if(p) cout<<root(p)<<endl;
else break;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator