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 TOBENO1 at 2013-04-21 15:03:29 on Problem 1503
#include<stdio.h>
#include<string.h>

int main(){
	char a[1000],b[1000],c[1010],d[1010];
	int m,n,r,i=0,p=0,s=0,count=1;
	gets(a);
    gets(b);
	for(;i<1010;i++)
		d[i]='0';
	n=strlen(b);
	for(i=n-1;i>=0;i--)
	{
			d[p]=b[i];
			p++;   
	}
	while(count<100)
	{
		if(count!=1)
			gets(a);
		if(a[0]=='0')
				break;
		for(i=0;i<1010;i++)
			c[i]='0';
		m=strlen(a);
		p=0;
		for(i=m-1;i>=0;i--)
		{
			c[p]=a[i];
			p++;
		}
		for(i=0;i<1010;i++)
		{
			r=c[i]+d[i]+s-96;
			s=r/10;
            d[i]=r%10+48;
		}
		count++;
	}
    for(i=1009;d[i]=='0';i--);
	for(;i>=0;i--)
		printf("%d",d[i]-'0');
	printf("\n");
	
	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