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 dingdongsheng at 2008-06-23 20:29:32 on Problem 1503
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int a[103];
int b[103];
char c[103];
void main()
{
	int i=0,j,x;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	while((c[i]=getchar())!='0')
	{
         while((c[++i]=getchar())!='\n')
			 ;
		 c[i]='\0';
		 strrev(c);
		 for(j=0;j<i;j++)
			 a[j]=c[j]-'0';
		 for(j=0;j<1039;j++)
		 {
			 b[j]+=a[j];
			 if(b[j]>=10)
			 {
				 b[j]-=10;
				 b[j+1]+=1;
			 }

		 }
		 i=0;
        memset(a,0,sizeof(a));
	}
	x=0;
	for(i=102;i>=0;i--)
	{
		if(x)
			printf("%d",b[i]);
		else if(b[i])
		{
			printf("%d",b[i]);
			x=true;
		}
	}
	printf("\n");
}

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