蔡子经数据结构1.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>

void overturn(int *a, int n)
{
int temp;
for(int i = 0; i < n/2; ++i)
{
temp = a[i];
a[i] = a[n-i-1];
a[n-i-1] = temp;
}
}

void print(int *a, int n)
{
for(int i = 0; i < n; ++i)
printf("%d ",a[i]);
puts("");
}

int main()
{
int a[10] = {0,1,2,3,4,5,6,7,8,9};
print(a, 10);
overturn(a, 10);
print(a, 10);
return 0;
}