chillurbrain

Task10_7_1

Dec 22nd, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <ctime>
  5. #include <conio.h>
  6.  
  7. using namespace std;
  8.  
  9. void shuffleArr(int *arr, int size)
  10. {
  11.     int buf;
  12.     int first, second;
  13.     for (int i = 0; i < rand() % 50 + 10; i++)
  14.     {
  15.         first = rand() % size;
  16.         second = rand() % size;
  17.         int buf = arr[first];
  18.         arr[first] = arr[second];
  19.         arr[second] = buf;
  20.     }
  21. }
  22.  
  23. int main()
  24. {
  25.     srand(time(NULL));
  26.     int arr[15];
  27.     for(int i = 0; i < 15; i++)
  28.         arr[i] = i;
  29.     shuffleArr(arr, 15);
  30.     for(int i = 0; i < 15; i++)
  31.         cout << arr[i] << endl;
  32.     _getch();
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment