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

几行代码ac,纪念下

Posted by seedeed at 2011-03-07 23:42:38 on Problem 1519
#include "cstdio"

int main()
{
	char buff[1000];
	int sum;
	while(scanf("%s",buff),buff[0]!='0')
	{
		sum=0;
		for(int i=0;buff[i];i++) sum+=buff[i]-'0';
		while(sum>9) sum=sum/10+sum%10;
		printf("%d\n",sum);
	}
	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