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

为什么不过,请教一下方法很笨,见笑!

Posted by wodie at 2005-03-20 01:28:38 on Problem 1519
#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:
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