//还没开始做,这次的时限只有2000分钟,明天要出去玩,今天先存一下以免过期了看不到了。
先写一个过了再说,想到了再来写。
#include <stdio.h>
void method1(int [],int);
void method2(int [],int);
void method3(int [],int);
void method4(int [],int);
int main(int argc, char const *argv[])
{
int a[5],i,k;
for(i=0;i<5;i++) scanf("%d",&a[i]);
method1(a,5);
for(i=1;i<=4;i++)
{
printf("METHOD %d\n",i);
for(k=0;k<5;k++)
printf("%d%c",a[k],k==4?'\n':' ');
}
return 0;
}
void method1(int a[],int n)
{
int i,tmp;
for(i=0;i<=n/2;i++)
{
tmp=a[i];
a[i]=a[n-i-1];
a[n-i-1]=tmp;
}
}
//Exchange head and tail
题目描述
Write a program that reads 5 integers into an array, and then uses four different methods of accessing the members of an array to print them out in the reverse order
输入样例
1
2
3
4
5
输出样例
METHOD 1
5 4 3 2 1
METHOD 2
5 4 3 2 1
METHOD 3
5 4 3 2 1
METHOD 4
5 4 3 2 1