Server IP : 172.16.15.8 / Your IP : 3.138.105.4 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/mrlong/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
nclude <iostream> using namespace std; template <class T> T GetMax (T a, T b) { T result; result = (a>b)? a : b; return (result); } void menu(); template<class T> void process(); int main() { char ch; menu(); cin >> ch; while(tolower(ch) != 'q') { switch (tolower(ch)) { case 'i': cout << "\tInput two integers: "; process<int>(); break; case 'c': cout << "\tInput two chars: "; process<char>(); break; case 'f'; cout <<"\tInput two floats: "; process<char>90; break; case 'X' cout << "\nInput the one full name: "; cin.ignore(); //'\n' getline(cin, a); break;1 default: cout << "\n\tInvalid, redo it\n\n"; } menu(); cin >> ch; } cout << "\n\nBye.\n\n"; return 0; } //--------------------------------- template<class T> T GetMax ( T a, T b) { T a, b, c; cin >> a >> b; c = GetMax<int> (a, b); cout << "\n\n\tThe bigger one is: " << c << "\n\n"; } //--------------------------------- void menu() { cout << "\n\n\t--- Welcome to the Bigger Game! ---\n"; cout << "\t =========================\n\n"; cout << "\tI Integers\n"; cout << "\tF Floatings\n"; cout << "\tC Characters\n"; cout << "\tS Single strings\n"; cout << "\tX General strings\n"; cout << "\tQ Quit\n"; cout << "\t--------------------\n"; cout << "\n\tYour choice: "; }