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 kings_zqz at 2007-04-14 21:22:06 on Problem 1519
#include<stdio.h>
int f(int n)
{
    int sum=0;
	if(n>=0&&n<=9) 
		return n;
	do{
			sum+=n%10;
			n=n/10;
		}while(n>0);
	return		f(sum);
	
}
void main()
{
	int n;
	scanf("%d",&n);
	while(n!=0)
	{
		printf("%d\n",f(n));
		scanf("%d",&n);

	}
}
为什么总是超时跟超出内存限制啊 

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