fork download
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. double *funkcja(int n, double tab[])
  8. {
  9. double *tab2 = tab;
  10.  
  11. return tab2;
  12. }
  13.  
  14. int main()
  15. {
  16. srand(time(NULL));
  17.  
  18. int n;
  19. cout << "n: "; cin >> n;
  20.  
  21. double tab[n];
  22. for(int i = 0; i < n; i++)
  23. {
  24. tab[i] = rand() % 100;
  25. cout << tab[i] << endl;
  26. }
  27. cout << endl;
  28.  
  29. double *tab2 = funkcja(n, tab);
  30. for(int i = 0; i < n; i++)
  31. {
  32. cout << tab2[i] << endl;
  33. }
  34. }
Success #stdin #stdout 0s 3344KB
stdin
5
stdout
n: 84
57
31
47
47

84
57
31
47
47