Advertisement
SergeyPGUTI

7.1.12

Nov 27th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include<cstdlib>
  4. #include<ctime>
  5.  
  6. using namespace std;
  7. int* generateRandomArray(int n)
  8. {
  9.     static int * mas=new int [n];
  10.     srand((unsigned)time(0));
  11.     int rnd;
  12.  
  13.     for(int i=0; i<n; i++)
  14.      {
  15.          rnd = (rand());
  16.          mas[i]=rnd;
  17.      }
  18.      return mas;
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24.     int n;
  25.     cin>>n;
  26.     int * NewMas=generateRandomArray(n);
  27.     for (int i=0;i<n;i++)
  28.     {
  29.         cout<<NewMas[i]<<endl;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement