杭電acm1279 角谷猜想

#include <iostream>    
using namespace std; 
int main()  
{  
    int n, m, count;  
    cin >> n;  
    while(n--) {  
        cin >> m;  
        count = 0;  
        while(m != 1) {  
            if(m & 1) {  
                if(count++)  
                    cout << " ";  
                cout << m;  
                m = 3 * m + 1;  
            } else  
                m >>= 1;    // m /= 2;  
        }  
        if(count == 0)  
            cout << "No number can be output !";  
        cout << endl;  
    }  
    return 0;  
}  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章