i declare a dynamic array int *idArray;
and i want to copy the value to a tempArray
, then i will change the order of tempArray
, but i don't want to change the order idArray
, how can i write it? I have tried to implement it, but when the order of tempArray
be changed, the order of idArray
also change.
int *idArray = new int[size];
int *tempArray = idArray;
int m, n;
for(int k = 0; k < size; k++) {
m = rand() % size;
n = tempArray[m];
tempArray[m] = tempArray[k];
tempArray[k] = n;
}