Server IP : 172.16.15.8 / Your IP : 3.145.66.104 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 (0755) : /home/kmmowery/cs212/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//-------------------------------------------------------------------------------- // // Author: Kieara Mowery // Date : 4/5/09 // File : Vector2.cpp // Due : 4/6/09 // Goal : insert a word to the list, delete the last word in the list, // reverse the word order in the list, sort the list to ascending // order, and print the number of the words in the list // //-------------------------------------------------------------------------------- #include <iostream> #include <vector> #include <algorithm> using namespace std; void menu(); int main() { vector<string> myList; string temp; char ch; menu(); cin >> ch; while( tolower (ch) != 'q') { cout << "\nYou Choose : " << ch; if ( tolower(ch) == 'i' ) { cout << "\nPlease insert a word: "; cin >> temp; myList.push_back(temp); cout << "\n" << temp << " is insterted to the list"; } else if ( tolower(ch) == 'p') { for (int i = 0; i < myList.size(); i++) cout << " \nThe list is: " << myList[i]; cout << " "; cout << endl; } else if ( tolower(ch) == 'r' ) { reverse ( myList.begin(), myList.end() ); cout << "\nAfter reversing the order of the list : " ; for ( int i = 0; i < myList.size(); i++ ) cout << myList[i] << " "; cout << endl; } else if ( tolower(ch) == 'b' ) { myList.pop_back(); cout << endl << "The last word inserted was deleted "; } else if ( tolower(ch) == 's') { sort(myList.begin(), myList.end() ); cout << "\nThe list is sorted\n "; } else if ( tolower(ch) == 'd') { sort(myList.begin(), myList.end(), greater<string>() ); cout << "\nThe list is sorted to descending order.\n"; } menu(); cin >> ch; } cout << "\n\nDone.\n\n"; return 0; } void menu() { cout << endl; cout << " List Game \n"; cout << "*************************************************\n"; cout << "I Insert an Integer.\n"; cout << "P Print the list.\n"; cout << "B To delete the last word.\n"; cout << "R Reverse the order.\n"; cout << "S Sort to ascending order.\n"; cout << "D Sort to descending order.\n"; cout << "Q Quit.\n"; cout << "*************************************************\n\n"; cout << "Your choice: "; }