Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <string>
- using namespace std;
- int getBalls();
- int getSlots();
- void printDirections(int, int);
- int main()
- {
- int balls = getBalls();
- int slots = getSlots();
- cout << endl;
- printDirections(balls, slots);
- }
- int getBalls()
- {
- cout << "Enter the amount of balls to drop: ";
- int balls;
- cin >> balls;
- return balls;
- }
- int getSlots()
- {
- cout << "Enter the amount of slots in the bean machine: ";
- int slots;
- cin >> slots;
- return slots;
- }
- void printDirections(int balls, int slots)
- {
- srand(time(0));
- string options[] = { "L", "R" };
- string direction = "";
- int choice[100];
- for (int j = 0; j < balls; j++)
- {
- direction = "";
- for (int i = 1; i < slots; i++)
- {
- choice[i] = rand() % 2;
- direction = direction + options[choice[i]];
- }
- cout << direction << endl;
- }
- cout << "" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement