// function prototypes int F(int x, int y); void Conway(int N); void Rounds(); void main() { // open text and drawing windows TinySquarePair(); //Problem 1---------------------- cout << "Problem 1" << endl; Conway(4); cout << endl; Conway(21); cout << endl; //Problem 2---------------------- int x = 1; int y = 3; cout << "Problem 2" << endl; cout << endl; for (int j = 1; j <=5; j++){ x = F(x, y); cout<< j<<" "<< x<<" "<< y<< endl; y = y + 3; } //Problem 3---------------------- Rounds(); PressReturn(); } // end main int F(int x, int y){ if (x < y) return 2*x; else return 2*y; } void Conway(int N){ if (N <= 0 ) cout << "error" <<endl; while (N > 1){ cout << N << endl; if ((N % 2) == 0) N = N/2; else N = 3*N + 1; } cout << N << endl; } void Rounds(){ int x = 160, y = 160, r = 40; while ( r > 5){ FrameCircle(x, y, r); x = x - r; y = y - r; r = r/2; x = x - r; y = y - r; } }
Problem 4.
Write a C++ function that returns true if its int argument is even and false otherwise.