PAT1001打卡-0826
2020-09-09 本文已影响0人
可爱的甜甜猪
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int k=0;
while(n!=1)
{
if(n%2==1)
n=(3*n+1)/2;
else
n=n/2;
k++;
}
cout<<k;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int k=0;
while(n!=1)
{
if(n%2==1)
n=(3*n+1)/2;
else
n=n/2;
k++;
}
cout<<k;
return 0;
}