Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void shuffle(int *a, int size) {
- int i, j, b;
- for (i = size - 1; i > 1; i--) {
- j = rand() % (i - 1);
- b = a[i];
- a[i] = a[j];
- a[j] = b;
- }
- }
- int main(void) {
- int i, j, size;
- int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- size = sizeof(a) / sizeof(int);
- for (i = 0; i < 20; i++) {
- shuffle(a, size);
- for (j = 0; j < size; j++) {
- printf("%d", a[j]);
- if (j < size - 1) printf(" ");
- }
- printf("\n");
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement