justinpuckett

Untitled

May 27th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <string>
  4. using namespace std;
  5.  
  6. string Direction(int);
  7. void printOutcomes(int, string);
  8.  
  9. int main()
  10. {
  11.  
  12.     cout << "Enter the amount of balls to drop: ";
  13.     int balls;
  14.     cin >> balls;
  15.  
  16.     cout << "Enter the amount of slots in the bean machine: ";
  17.     int slots;
  18.     cin >> slots;
  19.     cout << "" << endl;
  20.  
  21.     string direction = Direction(slots);
  22.     printOutcomes(balls, direction);
  23.  
  24.     return 0;
  25.  
  26. }
  27.  
  28. void printOutcomes(int balls, string direction)
  29. {
  30.    
  31.  
  32.     for (int j = 0; j < balls; j++)
  33.     {
  34.         cout << direction << endl;
  35.     }
  36.     cout << "" << endl;
  37.  
  38. }
  39.  
  40. string Direction(int slots)
  41. {
  42.     srand(time(0));
  43.     int choice[100];
  44.     string options[] = { "L", "R" };
  45.     string direction = "";
  46.    
  47.     for (int i = 1; i < slots; i++)
  48.     {
  49.         choice[i] = rand() % 2;
  50.         direction = direction + options[choice[i]];
  51.     }
  52.     return direction;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment