Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     srand(time(0));
  10.  
  11.     int polje[20];
  12.  
  13.     int min, max;
  14.  
  15.     for(int i = 0; i < 20; i++)
  16.     {
  17.         polje[i] = rand()%100 + 1;
  18.  
  19.         if(i == 0)
  20.         {
  21.             min = polje[i];
  22.             max = polje[i];
  23.         }
  24.         else
  25.         {
  26.             if(polje[i] > max)
  27.             {
  28.                 max = polje[i];
  29.             }
  30.  
  31.             if(polje[i] < min)
  32.             {
  33.                 min = polje[i];
  34.             }
  35.         }
  36.  
  37.         cout<<polje[i]<<" ";
  38.     }
  39.  
  40.     cout<<endl;
  41.  
  42.     cout<<"Maksimalna vrednost: "<<max<<endl;
  43.     cout<<"Minimalna vrednost: "<<min<<endl;
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement