/****************************************************************** * Pyramid Power * Mark Cruz * AP Computer Science * 12/05/02 * Inputz: The numeric values of five selected cards * Outputz: A completed Apex Pyramid to the extreme!! *******************************************************************/ #include // Function prototype int apex ( int b1, int b2, int b3, int b4, int b5 ); void main() { int b1, b2, b3, b4, b5, // b row topCard; // Pyramid apex // Read in the b row of cards. cout << endl << "Enter the values of the bottom row of cards (from left to right) now!: "; cin >> b1 >> b2 >> b3 >> b4 >> b5; // Compute the top card. topCard = apex(b1,b2,b3,b4,b5); // Output result. cout << endl << "I predict the card at the apex will be a " << topCard << endl << endl; cout << " " << topCard << endl; cout << " . ." << endl; cout << " . . ." << endl; cout << " . . . ." << endl; cout << " " << b1 << " " << b2 << " " << b3 << " " << b4 << " " << b5 << endl; } //-------------------------------------------------------------------- // Insert your apex() function here. //-------------------------------------------------------------------- int apex ( int b1, int b2, int b3, int b4, int b5 ) { int x = (b1+4*b2+6*b3+4*b4+b5)%9; if (x==0) return 9; else return x; } /*************************************************** Enter the values of the bottom row of cards (from left to right) now!: 9 9 9 9 9 I predict the card at the apex will be a 9 9 . . . . . . . . . 9 9 9 9 9 Press any key to continue ************************************************************************************ Enter the values of the bottom row of cards (from left to right) now!: 4 1 7 9 2 I predict the card at the apex will be a 7 7 . . . . . . . . . 4 1 7 9 2 Press any key to continue ************************************************************************************** Enter the values of the bottom row of cards (from left to right) now!: 2 4 6 4 3 I predict the card at the apex will be a 1 1 . . . . . . . . . 2 4 6 4 3 Press any key to continue */