| ||||||||||
| 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.h>
int root(int );
void main()
{
int a;
cin>>a;
while(a){
cout<<root(a)<<endl;
cin>>a;
}
}
int root(int a)
{
if((a/10)==0) return a;
else return root(a%10+a/10%10+a/100%10+a/1000%10+a/10000%10+a/100000%10+a/1000000%10+a/10000000%10+a/100000000%10+a/1000000000%10);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator