Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <random>
- #include <conio.h>
- void main()
- {
- int myArray[] = { 1,2,3,4,5,20,40,21,10,94,44 };
- int arrayLength = sizeof(myArray) / sizeof(int);
- for (size_t i = 0; i < arrayLength - 1; i++)
- {
- int index = rand() % (i + 1);
- int arrayTemp = myArray[index];
- myArray[index] = myArray[i];
- myArray[i] = arrayTemp;
- }
- for (int i = 0; i < arrayLength; i++) {
- printf("%d ", myArray[i]);
- //printf("\n");
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement