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

我的电脑上运行是对的,而提交后wrong answer.不知输入数组int a[100000]够不够大.若不够怎样设?

Posted by wangfanking at 2005-09-02 10:16:32 on Problem 1519
#include "stdio.h"
#include "malloc.h"


int exchange(int a)
{
	int result=0;

	while(a>10)
	{
		result=result+a%10;
		a=a/10;
	}
	result+=a;

	if(result>10)
	result=exchange(result);

	return result;

}



int main()
{
  int a[100000]={0},i=0,k=0;

    while(1)
	{
		scanf("%d",&a[i]);

		
		if(a[i]==0)break;
	    a[i]=exchange(a[i]);
		i++;
	}  
	while(a[k]!=0)
	{
		printf("%d\n",a[k]);
		k++;
	}
 

	return 0;
}

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