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

有那位朋友帮我测试一下,好多情况都考虑了,可还是wa

Posted by 21127149 at 2006-08-13 14:37:16 on Problem 1503
#include"stdio.h"
#include"string.h"
void main()
{
	char line[1000];
	int out[1200]={0},i,j,lenght,cin=0,sum,max=0;
	while(scanf("%s",line)>0)
	{
		if(strcmp(line,"0")==0)
		{
			for(i=max-1;i>=0;i--)
			{
				printf("%d",out[i]);
			}
			printf("\n");
		}
		lenght=strlen(line);
		j=0;
		for(i=lenght-1;i>=0;i--)
		{
			if(line[i]=='0')
			{
				sum=cin+out[j];
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='1')
			{
				sum=cin+out[j]+1;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='2')
			{
				sum=cin+out[j]+2;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='3')
			{
				sum=cin+out[j]+3;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='4')
			{
				sum=cin+out[j]+4;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='5')
			{
				sum=cin+out[j]+5;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='6')
			{
				sum=cin+out[j]+6;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='7')
			{
				sum=cin+out[j]+7;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='8')
			{
				sum=cin+out[j]+8;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			if(line[i]=='9')
			{
				sum=cin+out[j]+9;
				out[j]=(sum)%10;
				cin=(sum)/10;
			}
			j++;
		}
		for(i=lenght;cin!=0;i++)
		{
			
			out[i]=(cin+out[i])%10;
			cin=(cin+out[i])/10;
			lenght++;
		}
		if(max<lenght)
			max=lenght;		
	}
}

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