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

Re:去救 我的程序怎么会WA

Posted by qzw at 2009-04-03 17:14:31 on Problem 2562
In Reply To:去救 我的程序怎么会WA Posted by:382784268 at 2008-11-29 22:07:11
> 
> #include<iostream>
> 
> using namespace std;
> int main()
> {
> 	char a[11],b[11];
> 	int i;
> 	while((cin>>a>>b)&&(a[0]!='0')&&(b[0]!='0')){
> 	int n,m;
> 	n=strlen(a);
> 	m=strlen(b);
> 	int s[11];
> 	int t=0;
> 	int k=0;
> 	for(i=0;i<n/2;i++)
> 	{
> 		char g=a[i];
> 		a[i]=a[n-i-1];
> 		a[n-i-1]=g;
> 	}
> 	for(i=0;i<m/2;i++)
> 	{
> 		char g=b[i];
> 		b[i]=b[n-i-1];
> 		b[m-i-1]=g;
> 	}
> 		
> 	for(i=0;i<n&&i<m;i++)
> 	{
> 		s[i]=a[i]-48+b[i]-48+t;t=0;
> 		
> 		if(s[i]>9)
> 		{
> 			t=1;
> 			k++;
> 			s[i]-=10;
> 		}
> 	}
> 	
> 		
> 	if(n>m)
> 	{
> 		for(i=m;i<n;i++)
> 		{
> 			s[i]=t+a[i]-48;t=0;
> 			if(s[i]>9)
> 			{
> 				t=1;
> 				k++;
> 				s[i]-=10;
> 			}
> 		}
> 	}
> 	else
> 	{
> 		for(i=n;i<m;i++)
> 		{
> 			s[i]=t+b[i]-48;
> 			t=0;
> 			if(s[i]>10)
> 			{
> 				t=1;k++;
> 				s[i]-=10;
> 			}
> 		}
> 	}
> 	if(k!=0)
> 	{
> 		if(k==1)
> 		cout<<k<<" carry operation."<<endl;
> 		else
> 			cout<<k<<" carry operations."<<endl;
> 	}
> 	else
> 		cout<<"No carry operation."<<endl;
> 
> 	}
> 	return 0;
> }
901+99也过不了

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