Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.147.27.129
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  ]

Current File : /home/mrlong/assignment7b.cpp
//
//
//
//
//


#include <iostream>
#include <vector>
#include <algorithm>

#include "assignment7.h"

using namespace std;

// function prototypes
void menu ();
void process ( char );
//void showValues(vector<int>);

int main()
{
	//vector<string> v;
	string input;
	char menu_int;
	string garbage;
 		
	//v.push_back(input);

	menu(); // read first data
        cin >> menu_int; // ch: 1, 2, 3, 4, 5
        getline( cin, garbage );

	while ( menu_int != '8' )
        {
                process(menu_int);
                menu(); // read next data
                cin >> menu_int; // ch: 1, 2, 3, 4, 5, 6, 7, 8
                getline( cin, garbage ); // get rid of the newline
        }

        cout << "Press any key to exit the program. " << endl;
        getchar();
        return 0;

}

void menu ()
{
        cout << "1 Insert a string\n";
        cout << "2 Delete the last string\n";
        cout << "3 Sort to ascending order\n";
        cout << "4 Sort to descending order\n";
        cout << "5 Print the number of strings\n";
	cout <<	"6 Reverse the strings order\n";
	cout <<	"7 Empty the vector\n";
	cout << "8 Quit\n";

        cout << "\nYou choose: ";
}


void process ( char menu_int )
{
	vector<string> v;
        string input_string;
        switch ( menu_int )
                {
                        case '1':
                                cout <<"Enter string to insert: ";
                                cin >> input_string;
                                input_string.Assignment7();
				//v.push_back(input_string);
                                // for debug
                                cout << "The list is: ";
                                for( int i = 0; i < v.size(); i++ )
                			cout << v[i] << " ";
                                cout << "Type any key to continue ..";
                                getchar();
                                break;
                        case '2':
                                v.pop_back();
                                // for debug
                                cout << "The list is: ";			              		                    for( int i = 0; i < v.size(); i++ )
                                        cout << v[i] << " ";
                                cout << "\n\nType any key to continue ..";
                                getchar();
			case '3':
                                sort( v.begin(), v.end() );
                                cout << "\n\nType any key to continue ..";
                                getchar();
                                break;
                        case '4':
                                sort( v.begin(), v.end(), greater<string>() );
				cout << "\n\nType any key to continue ..";
                                getchar();
                                break;
                        case '5':
			//	v.size(input_string);
				cout << "\n\nType any key to continue ..";
                                getchar();
                                break;
			case '6':
				reverse(v.begin(), v.end());
				cout << "After reverse the order: ";
				for( int i = 0; i < v.size(); i++ )
                			cout << v[i] << " ";
				cout << "\n\nType any key to continue ..";
                                getchar();                               
				break;
			case '7':
			//	v.clear(input_string);
				cout << "\n\nType any key to continue ..";
                                getchar();
                                break;
			
	
		//	else
		//	
                //                cout << input_string
                //                        << " isn't in the list.\n";
                 //               cout << "\n\nType any key to continue ..";
                   //             getchar();
                     //           break;
			
                    //    default:
                      //          cout << "\nInvalid input.\n" ;
                        //        cout << "\n\nType any key to continue ..";
                          //      getchar();
        }
        return;
}


	

Stv3n404 - 2023