从键盘上输入10个整数,存储在一个长度为10的整型数组中,要求将输入的10个数逆序输出。
如输入为:0,1,2,3,4,5,6,7,8,9 输出为9,8,7,6,5,4,3,2,1,0
从键盘上输入10个整数,存储在一个长度为10的整型数组中,要求将输入的10个数逆序输出。
如输入为:0,1,2,3,4,5,6,7,8,9 输出为9,8,7,6,5,4,3,2,1,0
0 1 2 3 4 5 6 7 8 9
9
8
7
6
5
4
3
2
1
0
参考代码:
#include<stdio.h>
int main(){
	  int a[10];
	  for(int i=0;i<10;i++){
		    scanf("%d",&a[i]);
	  }
	  for(int i=0;i<5;i++){
		    int temp=a[i];
		    a[i]=a[9-i];
		    a[9-i]=temp;
	  }
	  for(int i=0;i<10;i++){
		    printf("%d\n",a[i]);
	  }
	  return 0;
}
 原文:http://www.cnblogs.com/zhhjthing/p/7750869.html