In your text file write a function that reverses an array of ints: void reverse(int* array, int numElements){ // your code here } Example input: int a[6] = {3,6,8,1,3,6} reverse(a, 6); // should result in {6,3,1,8,6,3}
时间: 2023-03-16 21:44:36 浏览: 93
Dietary glutamine supplementation partly reverses impaired macrophage function resulting from overload training in rats
答案:void reverse(int* array, int numElements){
int i, j, temp;
for (i = 0, j = numElements - 1; i < j; i++, j--) {
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
阅读全文