Advertisement
MeehoweCK

Untitled

Mar 15th, 2021
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. void wypisz(const int* t, const unsigned int n)
  8. {
  9.     for(unsigned int i = 0; i < n; ++i)
  10.         cout << t[i] << '\t';
  11.     cout << endl;
  12. }
  13.  
  14. void wypelnij(int* t, const unsigned int n)
  15. {
  16.     for(unsigned i = 0; i < n; ++i)
  17.         t[i] = rand() % 101;
  18. }
  19.  
  20. int main()
  21. {
  22.     cout << "Podaj wielkosc tablicy: ";
  23.     unsigned n;
  24.     cin >> n;
  25.     int* tablica = new int[n];      // rezerwujemy pamięć dla tablicy pięcioelementowej
  26.     wypelnij(tablica, n);           // wypełniamy tablicę
  27.     wypisz(tablica, n);             // wypisujemy tablicę
  28.  
  29.     delete[] tablica;               // zwolnienie pamięci
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement