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 cpp0600548020 at 2006-03-11 20:02:56 on Problem 1503
//不知道为啥总WA
#include<iostream.h>
#include<string.h>
void main()
{
	char a[101],sum[103];
	char *s=sum,*d;
	int i,j,p,l,t,flag=0;
	for(i=0;i<103;i++)
		sum[i]='0';
	for(i=1;i<=100;i++){
		cin>>a;
		p=0;
		l=strlen(a);
		for(i=0;i<l;i++)
			p+=a[i]-'0';
		if(p==0)break;
		for(i=102,j=l-1;j>=0;i--,j--){
			t=sum[i]-'0'+a[j]-'0';
			if(t>9){
				sum[i]=t-10+'0';
				sum[i-1]=sum[i-1]-'0'+1+'0';
			}
			else sum[i]=t+'0';
		}
	}
	for(s=sum;;s++)
		if(*s!='0')break;
	for(d=s;d<(sum+103);d++)
		cout<<*d;
	cout<<endl;
}

			


		
		


		

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