Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <windows.h>
  5. using namespace std;
  6.  
  7. int funkcja(void)
  8. {
  9.     srand(time(0));
  10.     double tab[30];
  11.     double max=tab[0];
  12.     int licznik=1;
  13.     for(int i=0; i<30 ; i++)
  14.     {
  15.         tab[i]=rand() % 10 + 1;
  16.         cout << i+1 << ": " << tab[i] << endl;
  17.         if(max<tab[i])
  18.         {
  19.             max=tab[i];
  20.             licznik=1;
  21.         }
  22.         else if(max==tab[i])
  23.             licznik++;
  24.     }
  25.     cout << "Max wynosi: " << max << " i wystapil " << licznik << " razy" << endl;
  26.     return(licznik);
  27. }
  28.  
  29. int main(int argc, char** argv)
  30. {
  31.     int tab[100];
  32.    
  33.     for(int i=0 ; i<100 ; i++)
  34.         tab[i]=funkcja();
  35.     for(int i=0 ; i<100 ; i++)
  36.         cout << i+1 << " : " << tab[i] << endl;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement