|
무엇이 잘못인지 알려주세요.
숫자 입력후에 디스플레이가 안돼요.
#include <iostream.h>
#include <ctype.h>
void DisplayIntroduction(void);
void DisplayMainMenu(void);
int GetMenuSelection(int Min, int Max);
void MenuSelection(int Select);
int GetIntegers(void);
void DisplayStatistics (void);
void Pause (void);
const int
MAX_NBR_INTEGERS = 30;
void main(void)
{
//int
// Nums[MAX_NBR_INTEGERS] = {0},
// NbrInteger = 0;
DisplayIntroduction();
//GetIntegers();
}
void DisplayIntroduction(void)
{
cout <<"This program calculates the mean, median, and mode"
<<"\nof up to 30 integers (each between 0 and 9)";
DisplayMainMenu();
}
void DisplayMainMenu(void)
{
cout <<"\n\nMain Menu"
<<"\n\t1. Enter integers"
<<"\n\t2. Display statistics"
<<"\n\t3. Clear integers"
<<"\n\t0. Exit"
<< "\n Choose an option ==> : ";
GetMenuSelection(0, 3);
}
int GetMenuSelection (int Min, int Max)
{
int
Select = Min - 1;
cin >> Select;
while((Select < Min)||(Select > Max))
{
cout << "\n ********** Error ********** !" << endl
<< " Please enter number in range 0 to 3 > ";
cin >> Select;
}
MenuSelection(Select);
return Select;
}
void MenuSelection(int Select)
{
int
Nums[30];
if (Select == 1)
{
GetIntegers();
}
else if (Select == 2)
{
DisplayStatistics();
for (int i = 0; i < MAX_NBR_INTEGERS; i++ )
cout << Nums[i] << " ";
}
}
int GetIntegers(void)
{
int
Nums[MAX_NBR_INTEGERS];
cout <<"\nEnter a string of integers (each between 0 and 9),ending in -1."
<<"\nAny more than 30 integers will be ignored."
<<"\nExample: 9 3 3 4 1 1 7 2 -1\n";
for (int i = 0; i < MAX_NBR_INTEGERS; i++ )
{
cin >> Nums[i];
if ((Nums[i] >9)||(Nums[i] < -1))
{
cout << "\nERROR:An invalid integer has been ignored: ";
cout << Nums[i]
<< "\n";
}
else if (Nums[i] == -1)
DisplayMainMenu();
}
return Nums[MAX_NBR_INTEGERS];
}
void DisplayStatistics (void)
{
int
Nums[MAX_NBR_INTEGERS];
cout << "Sorting Integers\n"
<< "\n================"
<< "\nThe unsorted integers:\n" ;
}
void Pause (void)
{
cout<<"\n\n\n\n Press enter to continue...";
char
ch = '\0';
cin.get(ch);
while ((ch != '\n')&&(ch != '\r'))
cin.get(ch);
}
|