SHARE
TWEET

Untitled

a guest Feb 14th, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include <ctime>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int brojac1 = 0,
  10.         brojac2 = 0,
  11.         brojac3 = 0,
  12.         brojac4 = 0,
  13.         brojac5 = 0,
  14.         brojac6 = 0,
  15.         n,
  16.         privremeni;
  17.  
  18.     srand(time(NULL));
  19.  
  20.     do
  21.     {
  22.         cout << "Unesite broj: " << endl;
  23.         cin >> n;
  24.  
  25.     } while (n < 10 || n > 1000);
  26.  
  27.     for (int i = 0; i < n; i++)
  28.     {
  29.         privremeni = rand() % 6 + 1;
  30.  
  31.         switch (privremeni)
  32.         {
  33.         case 1:
  34.             brojac1++;
  35.             break;
  36.         case 2:
  37.             brojac2++;
  38.             break;
  39.         case 3:
  40.             brojac3++;
  41.             break;
  42.         case 4:
  43.             brojac4++;
  44.             break;
  45.         case 5:
  46.             brojac5++;
  47.             break;
  48.         case 6:
  49.             brojac6++;
  50.             break;
  51.  
  52.         }
  53.  
  54.     }
  55.  
  56.     cout << "Procenat za broj 1: " << brojac1*1.0 / n * 100 << "%" << endl;
  57.     cout << "Procenat za broj 2: " << brojac2 * 1.0 / n * 100 << "%" << endl;
  58.     cout << "Procenat za broj 3: " << brojac3 * 1.0 / n * 100 << "%" << endl;
  59.     cout << "Procenat za broj 4: " << brojac4 * 1.0 / n * 100 << "%" << endl;
  60.     cout << "Procenat za broj 5: " << brojac5 * 1.0 / n * 100 << "%" << endl;
  61.     cout << "Procenat za broj 6: " << brojac6 * 1.0 / n * 100 << "%" << endl;
  62.  
  63.     system("pause>0");
  64.     return 0;
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top