program

closed account (ozTkSL3A)
Hey
Last edited on
I think you need two random indexes and swap the items.
1
2
3
4
5
6
7
8
int a[] = {'a','b','c','d','e','f','g','h','i','j'};

int index1 = rand() % 10;
int index2 = rand() % 10;

char temp = a[index1];
a[index1] = a[index2];
a[index2] = temp;


Make sure that index1 != index2
Topic archived. No new replies allowed.