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

????????????/怎么回事????这样都WA?(tzj115)

Posted by tzj115 at 2007-07-23 17:59:23 on Problem 1503
In Reply To:Why Posted by:luxuejuncarl at 2007-06-06 01:59:48
# include <stdio.h>
# include <string.h>
# include <iostream.h>

char s[105];

int d[105];

void qu_0(char s[])
{
	int i=0;
	int l=strlen(s);
	while(s[i]=='0')
		i++;
	for(int j=0;j<l-i;j++)
	{
		s[j]=s[j+i];
	}
	s[j]='\0';
	//return l-i;
}

void add(int d[],char s[])
{
	int len=strlen(s);
	s=strrev(s);
	int c=0;
	for(int i=0;i<len;i++)
	{
		d[i]+=c+(s[i]-'0');
		c=d[i]/10;
		d[i]%=10;
	}
	d[i]=c;
}

int main()
{
	memset(d,0,105*sizeof(int));
	cin>>s;
	qu_0(s);//////////////////////////////
	while(strcmp(s,"0"))
	{
		add(d,s);
		cin>>s;
		qu_0(s);//////////////////////////
	}
	int j=104;
	while(d[j]==0)
		j--;
	for(int m=j;m>=0;m--)
		cout<<d[m];
	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