-
Notifications
You must be signed in to change notification settings - Fork 377
/
SuperPrime2.cpp
66 lines (62 loc) · 1.21 KB
/
SuperPrime2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <vector>
class Nature {
private:
const int num; //数
public:
Nature(int n):num(n) {
}
~Nature();
Nature add(Nature sp); //求和
bool compare(Nature sp) { //比大小
if(num > sp.num)
return true;
return false;
}
};
class SuperPrime {
private:
std::vector<Nature> range; //超级素数的容器
public:
SuperPrime(int a, int b) {
for(int i = a; i < b; i++) {
Nature nat(i);
if(nat.isSuperPrime()) //过滤器
range.push_back(nat);
}
}
int max() {
for(std::vector<Nature>::iterate it = range.begin();
it != range.end(); it++) {
if(it->compare())
}
return 0;
}
int howmany() {
return range.size();
}
int sum() {
for(std::vector<Nature>::iterate it = range.begin();
it != range.end(); it++) {
}
}
private:
void split(int x) {
int a, sum, mult, sqrsum;
while(x != 0) {
a = x % 10;
sum += a;
mult *= a;
sqrsum += a*a;
x = x / 10;
}
}
};
int main()
{
SuperPrime sp(100, 999);
std::cout << "最大的超级素数:" << sp.max() << std::endl;
std::cout << "超级素数个数:" << sp.howmany() << std::endl;
std::cout << "超级素数的和:" << sp.sum() << std::endl;
return 0;
}