上学第一个星期的测验题 : 错在哪里
#include <iostream>
// Prototypes
void DisplayMenu();
int GetSelection();
////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
// Display the menu.
DisplayMenu();
// Get the menu selection.
int selection;
selection = GetSelection();
// Select the matching process
switch (selection)
{
case 1:
std::cout << "Processing Receivables" << std::endl;
break;
case 2:
std::cout << "Processing Payables" << std::endl;
break;
case 3:
std::cout << "Quitting" << std::endl;
break;
default:
std::cout << "\aInvalid selection" << std::endl;
break;
}
return 0;
}
////////////////////////////////////////
// Display a menu.
////////////////////////////////////////
void DisplayMenu()
{
std::cout << "--- Menu ---" << endl;
std::cout << "1=Receivables" << endl;
std::cout << "2=Payables" << endl;
std::cout << "3=Quit" << endl;
}
////////////////////////////////////////
// Read a menu selection from the
// keyboard.
////////////////////////////////////////
int GetSelection()
{
int selection;
std::cout << "Enter Selection: ";
std::cin >> selection;
return selection;
}
// Prototypes
void DisplayMenu();
int GetSelection();
////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
// Display the menu.
DisplayMenu();
// Get the menu selection.
int selection;
selection = GetSelection();
// Select the matching process
switch (selection)
{
case 1:
std::cout << "Processing Receivables" << std::endl;
break;
case 2:
std::cout << "Processing Payables" << std::endl;
break;
case 3:
std::cout << "Quitting" << std::endl;
break;
default:
std::cout << "\aInvalid selection" << std::endl;
break;
}
return 0;
}
////////////////////////////////////////
// Display a menu.
////////////////////////////////////////
void DisplayMenu()
{
std::cout << "--- Menu ---" << endl;
std::cout << "1=Receivables" << endl;
std::cout << "2=Payables" << endl;
std::cout << "3=Quit" << endl;
}
////////////////////////////////////////
// Read a menu selection from the
// keyboard.
////////////////////////////////////////
int GetSelection()
{
int selection;
std::cout << "Enter Selection: ";
std::cin >> selection;
return selection;
}