Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- // typ wyliczeniowy enum
- enum class kierunek
- {
- gora, lewo, prawo, dol
- };
- int main()
- {
- srand(time(nullptr));
- kierunek direction;
- for(int i = 0; i < 10; ++i)
- {
- direction = static_cast<kierunek>(rand() % 4); // rzutowanie statyczne
- switch(direction)
- {
- case kierunek::gora:
- cout << "w gore\n";
- break;
- case kierunek::dol:
- cout << "w dol\n";
- break;
- case kierunek::prawo:
- cout << "w prawo\n";
- break;
- case kierunek::lewo:
- cout << "w lewo\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement