PAT B1001 (3n+1) conjecture that kills people without paying for their lives (full score 15)

This question is entry-level and very simple.

#include<iostream>

using namespace std;

int main()
{
    
    
	int n;
	cin >> n;
	int count = 0;
	while (n > 1) 
	{
    
    
		if (n % 2 == 0)
			n /= 2;
		else
			n = (3 * n + 1) / 2;
		count++;
	}
	cout << count << endl;

	system("pause");
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_27538633/article/details/105935902