-
Notifications
You must be signed in to change notification settings - Fork 378
/
SuperPrime.cpp
57 lines (55 loc) · 1.21 KB
/
SuperPrime.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
#include <iostream>
#include <vector>
class Nature {
private:
int num;
public:
Nature():num(0){
std::cout << "Default Create Nature as " << num << std::endl;
}
Nature(int n):num(n) {
std::cout << "Create Nature as " << num << std::endl;
}
Nature(const Nature &nat):num(nat.num){
std::cout << "Copy Create Nature as " << num << std::endl;
}
~Nature() {
std::cout << "Destroy Nature as " << num << std::endl;
}
};
class SuperPrime {
private:
std::vector<Nature> natures;
public:
SuperPrime(int a, int b) {
std::cout << "Create SuperPrime from " << a << " to " << b << std::endl;
for(int i = a; i < b; i++) {
Nature nat(i);
std::cout << "HAHA" << std::endl;
natures.push_back(nat);
std::cout << "DDDDD" << std::endl;
}
}
~SuperPrime() {
std::cout << "Destroy SuperPrime " << std::endl;
}
Nature max() {
std::vector<Nature>::iterate it = natures.begin();
Nature max(0);
for(; it != natures.end(); it ++) {
if(it->isSuperPrime()) {
if (max.compare(*it)) {
max = *it;
}
}
}
return max;
}
};
int main() {
SuperPrime sp(10, 13);
Nature n = sp.max();
std::cout << "×î´ó³¬¼¶ËØÊý£º" ;
n.show();
return 0;
}