题目:将一个数组逆序输出
程序:
#include <stdio.h>
#define N 7
int main(void)
{
int a[N]={1,2,3,4,5,6,7};
int i,temp;
printf("The early array elements are:\n");
for(i = 0; i < 7; i++)
printf("a[%d]=%d\n",i,a[i]);
for(i = 0; i < N/2; i++)
{
temp = a[i];
a[i] = a[N-i-1];
a[N-i-1] = temp;
}
printf("The last array elements are:\n");
for(i = 0; i < 7; i++)
printf("a[%d]=%d\n",i,a[i]);
return 0;
}