MeehoweCK

Untitled

Mar 7th, 2023
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. // main.cpp
  2. #include "tabUtils.h"
  3. #include <iostream>
  4. #include <cstdlib>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. void wypelnienie_tablicy(int* tab, int rozmiar)
  10. {
  11.     srand(time(nullptr));
  12.     for(int i = 0; i < rozmiar; ++i)
  13.         tab[i] = rand();
  14. }
  15.  
  16. int main()
  17. {
  18.     int liczby[10];
  19.     wypelnienie_tablicy(liczby, 10);
  20.     printTab(liczby, 10);
  21.     return 0;
  22. }
  23.  
  24. // tabUtils.h
  25. #ifndef TABUTILS_H_INCLUDED
  26. #define TABUTILS_H_INCLUDED
  27.  
  28. void printTab(const int* const tab, unsigned int size);
  29. void reverseTab(int* const tab, unsigned int size);
  30.  
  31. #endif // TABUTILS_H_INCLUDED
  32.  
  33. // tabUtils.cpp
  34. #include "tabUtils.h"
  35. #include <iostream>
  36.  
  37. using namespace std;
  38.  
  39. void printTab(const int* const tab, unsigned int size)
  40. {
  41.     for(int i = 0; i < size; ++i)
  42.         cout << tab[i] << '\t';
  43.     cout << endl;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment