
 思路:使用判断语句即可,使用while进行循环,终止条件是n不等于1,然后用if-else判断奇数偶数
#include <iostream>
using namespace std;
int main(){
    int n;
    int count=0;
    cin>>n;
    
    while(n!=1){
        if(n%2==0){
            n/=2;
        }else{
            n=3*n+1;
            n/=2;
        }
        count++;
    }
    cout<<count;
}
                








](https://img-blog.csdnimg.cn/6d064cc98cb7481f8dd77a0c85b2fb20.png)









