fork download
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <ctime>
  4. using namespace std;
  5. void wstawB(int tab[],int n){ //funkcja zapełniająca tablicę
  6. tab[0]=rand()%20;
  7. for(int i=1;i<n;i++)
  8. tab[i]=rand()%10+tab[i-1];
  9. }
  10.  
  11. int main() {
  12. const int N = 20;
  13. int tab[N];
  14. srand(time(NULL));
  15. wstawB(tab,N);
  16.  
  17. for(int i = 0; i < N; i++)
  18. cout << tab[i] <<" ";
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
2 8 15 16 17 20 21 30 35 40 40 47 54 62 62 68 71 78 79 87