Advertisement
justinpuckett

Untitled

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