C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[7696] Re:Re:error display
kim [] 1625 읽음    2001-05-23 10:48
If user input 3, 8, 5, -1
after that display 3, 8, 5, -1
and display 3, 5, 8



박지훈.임프 님이 쓰신 글 :
: 임펠리테리입니다.
:
: "입력후 디스플레이가 안된다" 라고 하셨는데, 뭐가 디스플레이되기를 바라신 건지 모르겠네요.
: 컴파일해서 실행해보니 0부터 3까지의 메뉴가 뜨고 1번을 선택할 경우 숫자 리스트를 입력받던데,
: for 문으로 입력받은 숫자를 하나하나 루프를 돌 때마다 메뉴를 다시 출력시키는군요.
: 매번 사용자 입력을 받기 때문에 잘 모를 수도 있습니다만, 로직이 잘못되어서 재귀호출로 들어가는군요.
:
: 출력되길 바란 결과가 무언지는 알려주셔야 답변을 하겠죠?
: 보여주신 소스에 무언가를 출력하려는 시도가 전혀 없어서 님의 깊으신 뜻을 전혀 짐작할 수가 없군요. ^^;;
:
: 그럼 이만...
:
:
: kim 님이 쓰신 글 :
: : 무엇이 잘못인지 알려주세요.
: : 숫자 입력후에 디스플레이가 안돼요.
: :
: : #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);
: : }
: :
: :
: :

+ -

관련 글 리스트
7685 error display kim 1592 2001/05/22
7693     Re:error display 박지훈.임프 1473 2001/05/23
7696         Re:Re:error display kim 1625 2001/05/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.