Strzyk

generuj

Feb 2nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int* generujN(int N)
  9. {
  10. int* tmp;
  11. int i;
  12. srand(time(NULL));
  13. if (N<1)
  14. return 0;
  15. tmp=new int[N];
  16. for(i=0;i<N;i++)
  17. tmp[i]=rand()%11;
  18. return tmp;
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24. int *tab;
  25. int i,n;
  26.  
  27.  
  28. cout << "Podaj liczbe n"<<endl;
  29. cin >> n;
  30.  
  31. tab = generujN(n);
  32. for (i=0; i<n; ++i)
  33. cout<<tab[i]<< " ";
  34.  
  35. cout<<endl;
  36. delete [] tab;
  37.  
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment