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 zhangzhanbeast at 2005-03-22 21:38:00 on Problem 1503
考虑了各种数据,包括以0开头的数据。各种变态数据都测试成功了,但就是wrong answer.为什么?
#include<stdio.h>
#include<string.h>
void main()
{
	char a[102],b[103];
	int i,j,l1,l,k;
	for(i=0;i<103;i++)
		b[i]='0';
	for(i=0;i<101;i++)
	{
		scanf("%s",a);
		if(a[0]=='0'&&a[1]=='\0')
			break;
		l1=strlen(a);
		l=102;
		for(j=l1-1;j>=0;j--,l--)
		{
			b[l]+=a[j]-'0';
			if(b[l]>'9')
			{	
				b[l]-=10;
				b[l-1]++;
			}
		}
	}
	i=0;
	while(b[i]=='0')i++;
	for(k=i;k<=102;k++)
		printf("%c",b[k]);
}

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