Advertisement
JakubJaneczek

Zadanie 9

Apr 30th, 2020
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int a,b,c,d;
  10. int main()
  11. {
  12.     int tablica[10];
  13.     c=51;
  14.     srand(time(NULL));
  15.     for(int i=0;i<10;i++){
  16.         tablica[i]=1+rand()%(50-1+1);
  17.         cout << "Element tablicy" << i << "      " << tablica[i] << endl;
  18.         if(tablica[i]<c){
  19.             c=tablica[i];
  20.             d=i;
  21.         }
  22.         if(tablica[i]>a){
  23.             a=tablica[i];
  24.             b=i;
  25.         }
  26.     }
  27.     cout << endl << endl << "Najmniejszy element to["<<d<<"]wynosi: " << tablica[d] << endl;
  28.     cout << "Najwiekszy element["<<b<<"] wynosi: " << tablica[b];
  29.     cout << endl;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement