33,311
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include<stdio.h>
void main()
{
int a[5];
int i,j,temp;
printf("请输入: ");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
printf("逆序前: ");
for(i=0;i<5;i++)
printf("%d",a[i]);
for(i=0,j=4;i<j;i++,j--)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
printf("逆序后: ");
for(i=0;i<5;i++)
printf("%d",a[i]);
getchar();
}
#include <iostream.h>
int main()
{
int m[10],n;
cout<<"Please input the length of array(the length shoule <=10): "<<endl;
cin>>n;
for(int i=1;i<=n;i++)
cin>>m[i];
for(int j=n;j>0;j--)
cout<<" "<<m[j];
return 0;
}
const int n=10;
const int m=10;
#include <stdio.h>
main ()
{
int n=0,m=0;
int a[n],b[m]; // 数组下标必须是常量
printf ("Input counts \n");
for ( n=0 ; n!='\n' ; n++)
scanf ("%d",&a[n]);
for ( m=0 ; m <= n; m++ )
b[m] = a[n-m];
printf ("%3d",b[m]);
getch ();
}