Advertisement
bhok

Arrays Increasing Table

Jul 3rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <ctime>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8.  
  9.  
  10. int main()
  11. {
  12.  
  13.     const int arraySize = 7;
  14.     int frequency[arraySize] = {1}; // this sets all array elements to 0
  15.  
  16.    
  17.  
  18.     for (int i = 0; i < 120; ++i)
  19.     {
  20.         frequency[1 + rand() % 6]++;
  21.     }
  22.  
  23.     cout << "Face" << setw(13) << "Frequency" << endl;
  24.  
  25.     for (int face = 1; face < arraySize; ++face)
  26.     {
  27.         cout << setw(4) << face << setw(13) << frequency[face] << endl;
  28.     }
  29.     system("pause");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement