My Carelessness

Back to your page!


Or leave your comments here.

RegendLa

导航

关于数组的逆序重放

Q:将一个数组中的值按逆序重新存放。例如,原来的顺序为8,6,5,4,1。要求改为1,4,5,6,8。

输入为两行:第一行数组中元素的个数n(1<n<100),第二行是n个整数,每两个整数之间用空格分隔。

输出为一行:输出逆序后数组的整数,每两个整数之间用空格分隔。

S:

#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	int s[100];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s[i]);
	}
	for(int i=n;i>=1;i--)
	{
		printf("%d ",s[i]);
	}
	printf("\n");
	return 0;
}

 

posted on 2014-12-02 17:21  最爱七  阅读(888)  评论(0编辑  收藏  举报




Thanks for your coming!
If what you read helps,I would appreciate!