#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;
}
本文标题:PAT1001打卡-0826
本文链接:https://www.haomeiwen.com/subject/krsyektx.html
网友评论