我对交换主题有点新意,我被困住了。我必须将当前位置与数组中具有最高值的位置交换。这是我目前的代码。
void switchPlaces(string player[], int sum[], int numplayers) {
int high = 0;
for (int i = 0; i < numplayers; i++) {
int current = sum[i];
if (current > sum[high]) {
high = i;
}
int hold = sum[i];
sum[i] = high;
high = hold;
}
}