求个大佬救救孩子
查看原帖
求个大佬救救孩子
845879
yawningking楼主2023/2/24 19:34
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a = 0;
	int b[100]{ 0 };
	for (;; a++) {
		if (n % 2 == 0) {
			n /= 2;
			n = b[a];
		}
		else if (n % 2 != 0) {
			if (n != 1) {
				n = n * 3 + 1;
				n = b[a];
			}
			else if (n == 1) {
			n = b[a];
			break;
		}
		}
	}
	sort(b, b + 100);
	for (int i = 99-a; i <100; i++) {
		cout << b[i] << " ";
	}
	return 0;
}
2023/2/24 19:34
加载中...