Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <Windows.h>
- using namespace std;
- int main() {
- int brojevi[48] = { 0 };
- int najcesci[6] = { 0 };
- int * trenutniBrojeviUkrugu;
- srand(time(0));
- int brojrundi = 0;
- cout << "Koliko rundi zelite testirati: \n";
- cin >> brojrundi;
- int temp = 0, sho=0;
- for (int n = 0; n < brojrundi; n++) {
- trenutniBrojeviUkrugu = new int[35];
- for (int i = 0; i < 35; i++) {
- sho = 1;
- temp = rand() % 48;
- //cout << temp << endl;
- for (int j = 0; j < i; j++) {
- if (trenutniBrojeviUkrugu[j] == temp) {
- i--;
- sho = 0;
- break;
- }
- }
- if (sho==1)
- trenutniBrojeviUkrugu[i] = temp;
- Sleep(30);
- }
- for (int i = 0; i < 35; i++) {
- brojevi[trenutniBrojeviUkrugu[i]] += 1;
- }
- cout << ">Krug " << n+1 << endl;
- for (int i = 0; i < 35; i++) {
- cout << i+1 << ". broj: " << trenutniBrojeviUkrugu[i]+1 << endl;
- }
- delete[] trenutniBrojeviUkrugu;
- trenutniBrojeviUkrugu = nullptr;
- }
- for (int i = 0; i < 48; i++) {
- cout << i+1 << " se pojavio " << brojevi[i] << " puta.\n";
- }
- for (int i = 0; i < 6; i++) {
- najcesci[i] = 0;
- for (int j = 0; j < 47; j++) {
- if (najcesci[i] < brojevi[j]) {
- najcesci[i] = j;
- }
- }
- brojevi[najcesci[i]] = 0;
- }
- cout << "U " << brojrundi << " krugova, " << endl;
- for (int i = 0; i < 6; i++) {
- cout << i + 1 << "." << " najcesci broj je " << najcesci[i]+1 << endl;
- }
- system("pause>0");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement