Advertisement
MeehoweCK

Untitled

Dec 2nd, 2020
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. enum class kierunek
  7. {
  8.     gora = 73, lewo = 74, dol = 75, prawo = 76
  9. };
  10.  
  11. int main()
  12. {
  13.     char direction;
  14.     kierunek ruch;
  15.     for(short i = 0; i < 10; ++i)
  16.     {
  17.         do
  18.         {
  19.             direction = getch();
  20.             direction = toupper(direction);     // zwiększa do dużej litery
  21.  
  22.         }
  23.         while(direction != 'J' && direction != 'K' && direction != 'L' && direction != 'I');
  24.         ruch = static_cast<kierunek>(direction);
  25.  
  26.         switch(ruch)
  27.         {
  28.         case kierunek::gora:
  29.             cout << "w gore\n";
  30.             break;
  31.         case kierunek::dol:
  32.             cout << "w dol\n";
  33.             break;
  34.         case kierunek::lewo:
  35.             cout << "w lewo\n";
  36.             break;
  37.         case kierunek::prawo:
  38.             cout << "w prawo\n";
  39.             break;
  40.         }
  41.     }
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement