标签:one llb txt ilo dup gpm for gms snr
将n个数按输入输出顺序的逆序排列,用函数实现。
#include <stdio.h> int main(){ int n,i; void reverse(int * num, int n); printf("input n="); scanf("%d",&n); int num[20]; printf("输入%d个数.\n",n); for(i=0; i<n; i++){ scanf("%d",&num[i]); } reverse(num,n); //输出 for(i=0; i<n; i++){ printf("%4d",num[i]); } printf("\n"); return 0; } //逆序排序 void reverse(int * num, int n){ int temp,* end; end=num+n-1; while(num<end){ temp=*num; *num++ = *end; *end-- = temp; } }
结果:
标签:one llb txt ilo dup gpm for gms snr
原文地址:http://www.cnblogs.com/Allen-win/p/7278287.html