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 achilles at 2005-08-07 22:04:59 on Problem 1503
In Reply To:路过的。。行行好,,感激你。。。考虑了 开头 有0的整数,还错。。help.. Posted by:SilenceIowyh at 2005-08-07 21:56:16
#include<stdio.h>
#include<string.h>

int main()
{
	int a[200];
    char b[200];
	int i;
	
	for(i=0;i<200;i++)
		a[i]=0;
	while(1)
	{
		scanf("%s",b);
		if(strcmp(b,"0")==0)
			break;
		strrev(b);
		for(i=0;b[i]!='\0';i++)
			a[i]+=(b[i]-'0');
	}
	for(i=1;i<200;i++)
	{
		a[i]+=a[i-1]/10;
		a[i-1]=a[i-1]%10;
	}
   for(i=199;a[i]==0;i--);
	for(i;i>=0;i--)
		printf("%d",a[i]);
  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