Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <ctime>
- #include <cmath>
- using namespace std;
- int main()
- {
- int brojac1 = 0,
- brojac2 = 0,
- brojac3 = 0,
- brojac4 = 0,
- brojac5 = 0,
- brojac6 = 0,
- n,
- privremeni;
- srand(time(NULL));
- do
- {
- cout << "Unesite broj: " << endl;
- cin >> n;
- } while (n < 10 || n > 1000);
- for (int i = 0; i < n; i++)
- {
- privremeni = rand() % 6 + 1;
- switch (privremeni)
- {
- case 1:
- brojac1++;
- break;
- case 2:
- brojac2++;
- break;
- case 3:
- brojac3++;
- break;
- case 4:
- brojac4++;
- break;
- case 5:
- brojac5++;
- break;
- case 6:
- brojac6++;
- break;
- }
- }
- cout << "Procenat za broj 1: " << brojac1*1.0 / n * 100 << "%" << endl;
- cout << "Procenat za broj 2: " << brojac2 * 1.0 / n * 100 << "%" << endl;
- cout << "Procenat za broj 3: " << brojac3 * 1.0 / n * 100 << "%" << endl;
- cout << "Procenat za broj 4: " << brojac4 * 1.0 / n * 100 << "%" << endl;
- cout << "Procenat za broj 5: " << brojac5 * 1.0 / n * 100 << "%" << endl;
- cout << "Procenat za broj 6: " << brojac6 * 1.0 / n * 100 << "%" << endl;
- system("pause>0");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement