#include <stdio.h>
void print_array(int[], int);
void reverse_array(int[],int);
int main(int argc, int *argv[])
{
int a[11] = {3,5,7,123,786,16,13,64,97,600,88};
print_array(a,11);
reverse_array(a,11);
print_array(a,11);
system("pause");
return 0;
}
void print_array(int array[],int n)
{
int i;
for (i = 0;i < n; i++)
{
printf("%d ",array[i]);
}
printf("\n");
}
void reverse_array(int array[], int n)
{
int begin = 0,end = n - 1,mid = n / 2,temp;
int i;
for (i = 0; i < mid; i++)
{
temp = array[begin];
array[begin] = array[end];
array[end] = temp;
begin++;
end--;
}
}
|