why?25分
查看原帖
why?25分
742482
Yu09217777楼主2022/11/6 10:20
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	while (n != 1){
		if (n % 2 == 1){
			cout << n << " * 3 + 1 = " << n * 3 + 1 << endl;
			n = n * 3 + 1;
		}else if (n % 2 == 0){
			cout << n << " / 2 = " << n / 2 << endl;
			n = n / 2;
		} 
	}
	cout << "End" << endl;
	return 0;
}
2022/11/6 10:20
加载中...