Advertisement
Guest User

Untitled

a guest
May 29th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. //Function that runs the ranbom numbers
  6. int Stream(int x)
  7. {
  8.     int p = 0;
  9.     srand(time(0));
  10.    
  11.         x = x - 1;
  12.         while (x > 0)
  13.         {
  14.  
  15.             int k = rand() % 2;
  16.             if (k == 0)
  17.                 cout << "L";
  18.             else
  19.             {
  20.                 cout << "R";
  21.                 p += 1;
  22.             }
  23.             x--;
  24.            
  25.  
  26.         }
  27.        
  28.         cout << "" << endl;
  29.        
  30.         return p;
  31.  
  32.  
  33.     }
  34.  
  35. //Function that determines which array the combination falls under
  36. int Poles(int x)
  37. {
  38.     int k = Stream(x);
  39.  
  40.     int slot[10];
  41.    
  42.     for (int i = 0; i < x; i++)             //Define the arrays
  43.         slot[i] = i;
  44.    
  45.     cout << "your ball went in  slot "
  46.         << slot[k] << endl;
  47.  
  48.  
  49.    
  50.     return 0;
  51.  
  52. }
  53.  
  54.     int main()
  55.     {
  56.  
  57.         int x, y;
  58.         cout << "Enter the number of balls: \n";
  59.         cin >> y;
  60.         cout << "Enter a length \n";
  61.         cin >> x;
  62.  
  63.     while (y > 0)
  64.         {
  65.         Poles(x);
  66.    
  67.    
  68.             system("pause");                //Allows there to be time difference in random numbers
  69.     y--;
  70.         }
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement