cpp07.cpp

来自「C++参考书」· C++ 代码 · 共 56 行

CPP
56
字号

// Coded by plusir -- Dec.27.2002.
// Standard C++ Bible -- (P96-4-7)

#include <iostream>
using namespace std ;

void displayMenu( void ) ;
int getSelection( void ) ;

int main()
{
	int selection = 0 ;

	while ( selection != 3 ) {

        displayMenu() ;

		selection = getSelection() ;

		switch ( selection ) {
			case 1:
				cout << "Processing Receivables" << endl ;
				break ;
			case 2:
				cout << "Processing Payables" << endl ;
				break ;
			case 3:
				cout << "Quitting" << endl ;
				break ;
			default:
				cout << "\aInvalid selection" << endl ;
				break ;
		}
	}

	return 0 ;
}

void displayMenu( void )
{
	cout << "--- Menu ---" << endl ;
	cout << " 1 - Receivalbes" << endl ;
	cout << " 2 - Payables" << endl ;
	cout << " 3 - Quit" << endl ;
}

int getSelection( void )
{
	int selection ;
	cout << "Enter a integer: " ;
	cin >> selection ;

	return selection ;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?