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

Why WA?

Posted by oysiya at 2006-10-22 14:50:14 on Problem 1519
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void main()
{
	int n,i;
	char a[15];
	while(1)
	{
		scanf("%d",&n);
		if(n==0)
			break;
		while(n>9)
		{
			itoa(n,a,10);
			n=0;
			for(i=0;i<strlen(a);i++)
			{
				n+=a[i]-'0';
			}
		}
		printf("%d\n",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