#include
#include
#define ARR_SIZE 10
int reverse(int arr[]) {
int arr_tmp[ARR_SIZE] = {0};
int i;
for (i = 0;i < ARR_SIZE;i++) {
arr_tmp[ARR_SIZE-i-1] = arr[i];
}
for ( i = 0;i < ARR_SIZE;i++) {
arr[i] = arr_tmp[i];
}
}
void show_arr(int arr[]) {
int i;
for (i = 0; i < ARR_SIZE;i++) {
printf("%d ",arr[i]);
}
printf("\n");
}
int main(int argc,char *argv[]) {
int i;
int arr[ARR_SIZE] = {0};
srand(time(NULL));
for (i = 0; i < ARR_SIZE; i++) {
arr[i] = rand()%100;
}
printf("before reverse...\n");
show_arr(arr);
reverse(arr);
printf("after reverse...\n");
show_arr(arr);
}
结果: