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

过了,但是不知道为什么。为什么把cin>>a>>b;拿到外面来下面再写一次就行?如下

Posted by faononl at 2004-03-02 22:24:39 on Problem 1207
In Reply To:555,这都不过……,哪位帮看看 Posted by:faononl at 2004-03-02 19:38:00
#include <iostream.h>
void main()
{
	int a, b ,i ,num , max ,temp ;
cin >> a >> b ;
	while(cin)
{

	
	max = 0 ;
	cout << a << ' ' << b ;
	if ( a >b ) {temp = a ;a = b ;b = temp ;}
	for( i = a ; i<=b ; i++ )
	{
		temp = i ;
		num = 1 ;
		while(temp != 1 )
		{
			if ( temp % 2 == 0 ) temp/=2 ;
			else temp=temp*3+1 ;
			num++ ;
		}
		if ( num > max ) max = num ;
	}
	cout << ' ' << max << endl;
	cin >> a >> b ;
}
}

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