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

why wa?,能否看看?

Posted by chenmingqiang at 2006-03-21 13:45:01 on Problem 1503
#include<stdio.h>
#include<string.h>
int main()
{	
	int i,j,m,n;
	char r[104];
	for(i=0;i<103;i++)
		r[i]='0';
		r[103]='\0';
	char s[101];
	while(1)
	{
		scanf("%s",s);
		if(strcmp(s,"0")==0)
			break;
		else
			for(i=102,j=strlen(s)-1;i>=102-strlen(s)+1;i--,j--)
			{
				m=r[i]-'0'+s[j]-'0';
				n=m%10;
				m=m/10;
				r[i]=n+'0';
				if(m)
				  	r[i-1]+=m;
			}
	}
	for(i=0;i<103;i++)
		if(r[i]!='0')
			break;
	for(j=i;j<103;j++)
		printf("%c",r[j]);
	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