Advertisement
SergeyPGUTI

7.1.10

Nov 27th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include<cstdlib>
  4. #include<ctime>
  5.  
  6. using namespace std;
  7. void shuffleArr(int *arr, int size)
  8. {
  9.     srand((unsigned)time(0));
  10.     int rnd;
  11.     int temp;
  12.     for(int i=0; i<size; i++)
  13.      { //генерация 20 случайных чисел
  14.         rnd = (rand()%size); //генерация случайного числа в диапазоне от 1 до 10
  15.         temp=arr[i];
  16.         arr[i]=arr[rnd];
  17.         arr[rnd]=temp;
  18.      }
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24.     int n;
  25.     cin>>n;
  26.     int *Mas=new int[n];
  27.     int *p[n];
  28.     for (int i=0;i<n;i++)
  29.     {
  30.         cin>>Mas[i];
  31.     }
  32.     shuffleArr(Mas,n);
  33.     for (int i=0;i<n;i++)
  34.     {
  35.         cout<<Mas[i]<<endl;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement