//----------------------------------------------------------------------------- //mersen number (2^s)-1 bool PrimeTester::TestLukaLemera(Integer degree) { Integer Three("3"); if (degree < Three) throw new Exception("Степень меньше 3"); Integer s = degree; Integer sqrt = degree.Sqrt(); for(Integer i("2"); i <= sqrt; i++) { Integer quotient = (Mersen_Number)/i; if( i*quotient == (Mersen_Number)) return false; } Integer u("4"); Integer j("2"); for(Integer k("1"); k <= s - j; k++) { u = (u*u - j) % (Mersen_Number); if(u.isZero()) return true; } return false; }
bool Sub(void) { bool ok = true; ok &= One(); ok &= Two(); ok &= Three(); ok &= Four(); return ok; }
void g (N::A *a, M::B *b, O::C *c) { One (a); // ok One (a, b); // ok One (b); // { dg-error "not declared" } // { dg-message "suggested alternatives" "suggested alternative for One" { target *-*-* } 34 } Two (c); // ok Two (a, c); // ok Two (a); // { dg-error "not declared" } // { dg-message "suggested alternatives" "suggested alternative for Two" { target *-*-* } 39 } Two (a, a); // error masked by earlier error Two (b); // error masked by earlier error Two (a, b); // error masked by earlier error Three (b); // ok Three (a, b); // ok Three (a); // { dg-error "not declared" } // { dg-message "suggested alternatives" "suggested alternative for Three" { target *-*-* } 47 } }
int main() { // 반환 값을 담을 변수 int ret; // 함수를 호출하고 반환 값을 보관 ret = Three(); // 결과 출력 std::cout << "ret = " << ret << "\n"; return 0; }
void main(void) { SomeClass One(1, 999); cout << "One: " << One.my_data << ' ' << One.count << endl ; // Declare another instance SomeClass Two(2); cout << "Two: " << Two.my_data << ' ' << Two.count << endl ; // Declare another instance SomeClass Three(3); cout << "Three: " << Three.my_data << ' ' << Three.count << endl ; }
// ------------------------------------------------------------------------ int main( void ) { cout <<" ID Name\n"; Ball One; cerr <<"a. " << One <<endl; // Default constructor Ball Two( 75 ); cerr <<"b. " << Two <<endl; // Normal constructor Ball Three("Ali"); cerr <<"c. " << Three <<endl; // Normal constructor Ball Four( One ); cerr <<"d. " << Four <<endl; // Copy constructor Ball Five = Three; cerr <<"e. " << Five <<endl; // Copy Constructor cout << "\nReady to construct an array:" <<"\n"; Ball Six[2]; cerr <<"\t" <<"f. "<< Six[0] <<"\t " <<Six[1] <<"\n"; // Ball Bad = Ball(77); // Bad: Ball(77) not a Ball& cerr <<"\nNow " << One.getcount() <<" Ball objects have been created.\n"; Four = Two; cerr << "g............................\n" // Assignment <<"\t" << Four <<"\n\t" << Two <<endl; bye(); return 0; }
int main(int argc, const char * argv[]) { printf("You are now going to start the game: Kobe"); Three(); }