将数组中的数逆序重新排放

/*
将数组中的数逆序重新排放 
*/
#include<stdio.h>
void fun(int a[],int n){
    int i,t;
    for(i=0;i<n/2;i++){
        t=a[i];
        a[i]=a[n-1-i];
        a[n-1-i]=t;
    }
}
int main(){
    int a[5],i;
    printf("请输入5个数:
");
    for(i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    fun(a,5);
    printf("重新排序后的数组:
");
    for(i=0;i<5;i++){
        printf("%4d",a[i]);
    }
    return 0;
} 

收录于文章《885程序设计考点狂背总目录中

一纸高中万里风,寒窗读破华堂空。 莫道长安花看尽,由来枝叶几相同?
原文地址:https://www.cnblogs.com/byczyz/p/13528721.html