question4-2.cpp

来自「This is solution code c++ in class lesso」· C++ 代码 · 共 21 行

CPP
21
字号
#include<iostream>
using namespace std;
int main()
{   
    int n;
    cout << "Enter any positive integer greater than 1:";
    cin >> n;
    cout << "the sequence will be " << n;
    while (n > 1)
    {
         if (n % 2 == 0)
            n = n / 2;
         else
             n = n * 3 + 1;
         cout << " " << n;
    } 
    cout << endl;
    system("pause");
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?