解题思路:
注意事项:
参考代码:
#include<bits/stdc++.h>
using namespace std;
int p[10001] = {0};
int main() {
for (int i = 2; i <= 10000; i++) {
if (!p[i])
for (int j = i+i; j <= 10000; j+=i) {
p[j] = 1;
}
}
int a, b;
cin >> a >> b;
for (int i = a; i <= b; i++) {
cout << i << "=";
if (p[i] == 0) cout << i;
else {
int s = i;
for (int j = 2; j <= i; j++) {
while (1) {
if (s % j == 0) {
//int t = s/j;
cout << j;
s = s / j;
if (s != 1) cout << "*";
}
else {
break;
}
}
if (s == 1) break;
}
}
cout << endl;
}
}
0.0分
1 人评分