⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 question4-2.cpp

📁 This is solution code c++ in class lesson.
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -