Advertisement
MeehoweCK

Untitled

Mar 15th, 2021
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. // zadanie 4.
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void modyfikuj(int* tab, const unsigned n)
  7. {
  8.     for(unsigned i = 0; i < n / 2; ++i)
  9.         tab[i] = 0;
  10.     for(unsigned i = n / 2; i < n; ++i)
  11.         tab[i] = i + 1;
  12. }
  13.  
  14. void wypisz(const int* tab, const unsigned n)
  15. {
  16.     for(unsigned i = 0; i < n; ++i)
  17.         cout << tab[i] << '\t';
  18.     cout << endl;
  19. }
  20.  
  21. int main()
  22. {
  23.     unsigned n;
  24.     cout << "Podaj wielkosc tablicy: ";
  25.     cin >> n;
  26.  
  27.     int* tab = new int[n];
  28.     modyfikuj(tab, n);
  29.     wypisz(tab, n);
  30.     delete[] tab;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement