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 |
过了,但是不知道为什么。为什么把cin>>a>>b;拿到外面来下面再写一次就行?如下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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator