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 frkstyc at 2005-11-02 23:29:28 on Problem 1519
In Reply To:这也AC了? Posted by:teamwolves at 2005-11-02 23:25:17
> 
> #include <stdio.h>
> #include <string.h>
> char strInput[50];//应该用5000才对吧?
> int main()
> {
> 	int res,i,a,b,c,d,x;
> 	while (1)
> 	{
> 		res = 0;
> 		scanf("%s",strInput);
> 		if (strcmp(strInput,"0")==0) 
> 			return 0;
> 		x = strlen(strInput);
> 		for (i=0;i<x;i++)
> 			res +=strInput[i]-'0';
> 		while (res>=10) 
> 		{
> 			a = res/1000;
> 			b = (res-a*1000)/100;
> 			c = (res-a*1000-b*100)/10;
> 			d = res%10;
> 			res = a+b+c+d;
> 		}
> 		printf("%d\n",res);
> 	}
> 	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