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 zhangliqiang at 2007-09-17 12:07:59 on Problem 1519
那位高手帮忙看看,我错在哪儿了!
#include<string.h>
#include<stdio.h>
int main()
{
	char s[10000000];
	int i,temp,j,sum;
	while(scanf("%s",s))
	{	
		sum=0;
		if(strcmp(s,"0")==0)
			break;
		for(i=0;i<strlen(s);i++)
			sum=sum+s[i]-'0';
		while(sum>=10)
		{
			i=0;temp=sum;
			while(temp>=10)
			{
				i=+temp%10;
				temp=temp/10;
			}
			i=i+temp;
			sum=i;
		}
		j=0;temp=0;
		while(j<strlen(s))
		{
			if(temp<sum)
			{
				temp=temp*10+(s[j]-'0');
				temp=temp%sum;
				j=j+1;
			}
			else
			{
				temp=temp+s[j]-'0';temp=temp%sum;j++;
			}
		}
		if(temp==0)
		{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