diff --git a/SuperPrime_HW2.cpp b/SuperPrime_HW2.cpp index ec1c77f3..3f3daae2 100644 --- a/SuperPrime_HW2.cpp +++ b/SuperPrime_HW2.cpp @@ -19,7 +19,7 @@ class Nature { bool isPrime() { if(num == 1 || num == 0) return false; - for(int i = 2; i <= (int)sqrt(num); i++) + for(int i = 2; i <= (int)num; i++) { if(num % i == 0) return false; @@ -34,7 +34,10 @@ class Nature { return -1; } -private: + show() + { + std::cout< nat.num) return 1; @@ -73,8 +86,8 @@ class Container { std::cout << "Destroy SuperPrime " << std::endl; } - SuperPrime max() { - std::vector::iterate it = natures.begin(); + Nature max() { + std::vector::iterator it = natures.begin(); Nature max(0); for(; it != natures.end(); it ++) { if (max.compare(*it)) { @@ -85,9 +98,9 @@ class Container { } }; int main() { - SuperPrime sp(10, 13); + Container sp(100,999); Nature n = sp.max(); - std::cout << "��󳬼�������" ; + std::cout<<"最大:"; n.show(); return 0;