// function prototypes int F(int x, int y); void Conway(int N); void Circles(); void main() { // open text and drawing windows TinySquarePair(); //Problem 3---------------------- cout << "Problem 1" << endl; Conway(8); cout << endl; Conway(3); cout << endl; //Problem 3---------------------- int x = 1; int y = 5; cout << "Problem 2" << endl; cout << endl; for (int j = 1; j <=5; j++){ cout<< j<<" "<< x<<" "<< y<< endl; x = F(x, y); y = F(x, y); } //Problem 3---------------------- Circles(); 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 Circles(){ int x = 10, r = 10; while (x + r < 200){ FrameCircle(x, 100, r); x = x + r; r = 2*r; x = x + r; } }
Problem 4.
Write a C++ function that takes two int arguments and returns their average.