| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
你自己想想while的判断顺序就明白了In Reply To:过了,但是不知道为什么。为什么把cin>>a>>b;拿到外面来下面再写一次就行?如下 Posted by:faononl at 2004-03-02 22:24:39 > #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator