Advertisement
Guest User

Menu

a guest
Oct 19th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. void gotoxy( const int x, const int y )
  8. {
  9.     COORD coord = { x, y };
  10.     SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );
  11. }
  12.  
  13. int OpcjaA()
  14. {
  15.     return 0;
  16. }
  17.  
  18. int OpcjaB()
  19. {
  20.     return 0;
  21. }
  22.  
  23. int main()
  24. {
  25.     int wybor;
  26.     int poprzedniWybor;
  27.     bool wykonujPetle;
  28.    
  29.     while( 1 )
  30.     {
  31.         wybor = 0;
  32.         poprzedniWybor = wybor;
  33.         wykonujPetle = true;
  34.        
  35.         system( "cls" );
  36.         gotoxy( 3, 1 );
  37.         cout << "Opcja A";
  38.         gotoxy( 3, 3 );
  39.         cout << "Opcja B";
  40.         gotoxy( 3, 5 );
  41.         cout << "Exit";
  42.        
  43.         while( wykonujPetle )
  44.         {
  45.             gotoxy( 1, wybor * 2 + 1 );
  46.             cout << static_cast < char >( 16 );
  47.            
  48.             poprzedniWybor = wybor;
  49.             switch( getch() )
  50.             {
  51.             case 224:
  52.                 switch( getch() )
  53.                 {
  54.                 case 72:
  55.                     if( 0 < wybor ) wybor--;
  56.                     else wybor = 2;
  57.                    
  58.                     break;
  59.                    
  60.                 case 80:
  61.                     if( wybor < 2 ) wybor++;
  62.                     else wybor = 0;
  63.                    
  64.                     break;
  65.                    
  66.                 case 77:
  67.                     switch( wybor )
  68.                     {
  69.                     case 0:
  70.                         OpcjaA();
  71.                         break;
  72.                        
  73.                     case 1:
  74.                         OpcjaB();
  75.                         break;
  76.                        
  77.                     case 2:
  78.                         return 0;
  79.                     }
  80.                 }
  81.                 break;
  82.             }
  83.            
  84.             gotoxy( 1, poprzedniWybor * 2 + 1 );
  85.             cout << " ";
  86.         }
  87.     }
  88.     return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement