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