Michal_Pilarski

zad9 tablice

Apr 17th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int tab[10];
  9.     int najw=1,najm=50;
  10.     srand(time(NULL));
  11.     for(int i=0; i<10; i++)
  12.     {
  13.         tab[i] = rand()%50+1;
  14.         if(tab[i] > najw)
  15.         {
  16.             najw = tab[i];
  17.         }
  18.         if(tab[i] < najm)
  19.         {
  20.             najm = tab[i];
  21.         }
  22.         cout<<tab[i]<<endl;
  23.  
  24.     }
  25.     cout<<"Najmniejsza liczba: "<<najm<<endl;
  26.     cout<<"Najwieksza liczba: "<<najw;
  27.     return 0;
  28. }
Add Comment
Please, Sign In to add comment