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 lbp at 2005-08-13 10:11:58 on Problem 2562
这也能错?
#include<iostream.h>
#include<math.h>

void main()
{
	while(1){
		long int a,b;
		cin>>a>>b;
		if(a==0&&b==0) break;
		int ar1[15],ar2[15];
		int count1=1,count2=1;

		for(int i=0;;i++){
			ar1[i]=a%10;
			a/=10;
			if(a==0) break;
			else count1++;
		}
		for(i=0;;i++){
			ar2[i]=b%10;
			b/=10;
			if(b==0) break;
			else count2++;
		}

		//cout<<count1<<" "<<count2<<endl;
		int count=0;
		int carry=0;
		int ok;
		if(count1>count2)
			ok=count2;
		else
			ok=count1;
		for(i=0;i<ok;i++){
			if(ar1[i]+ar2[i]+carry>=10){
				count++;
				carry=1;
			}
			else carry=0;
		}

		if(count==0)
			cout<<"No carry operation."<<endl;
		else if(count==1)
			cout<<count<<" carry operation."<<endl;
		else 
			cout<<count<<" carry operations."<<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