Files
python/TangDou/LuoGuBook/L21_11_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

27 lines
478 B
C++

#include <bits/stdc++.h>
using namespace std;
//分解质因数
const int N = 110;
int a[N];
int divide(int x) {
int cnt = 0;
for (int i = 2; i <= x / i; i++)
while (x % i == 0) {
a[++cnt] = i;
x /= i;
}
if (x > 1)a[++cnt] = x;
return cnt;
}
int main() {
int cnt = divide(8);
for (int i = 1; i <= cnt; i++) {
if (i > 1) printf("*");
cout << a[i];
}
return 0;
}