'commit'
This commit is contained in:
27
TangDou/LuoGuBook/L21_11_2.cpp
Normal file
27
TangDou/LuoGuBook/L21_11_2.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user