[Arrays]D. Liang 6.3 Reversing the numbers entered.c

Description

Write a program that reads n integers and displays them in reverse order in which they were read.

Input

The first line is a positive integer t for the number of test cases.
Each test case contains two lines. The first line is an integer n (0<n<=100). The second line contains n integers.

Output

For each test case, outputs the n numbers in reverse order in which they were read, seperated by one blank.

Sample Input

2
3
1 2 3
4
2 1 2 1

Sample Output

3 2 1
1 2 1 2
//   Date:2020/4/9
//   Author:xiezhg5
#include <stdio.h>
int main(void)
{
	int a[100]={0};      //定义数组并初始化 
	int m,n,i;
	scanf("%d\n",&m);  //不要忘记加回车符 
	while(m>0)
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			//将输入的数字存放在a数组中 
			scanf("%d",&a[i]);
		}
		//利用数组特性逆序输出个位数 
		for(i=n-1;i>=0;i--)
		{
			printf("%d ",a[i]);
		}
		printf("\n");  //标测要求换行 
		m--;
	}
	return 0;
}
发布了208 篇原创文章 · 获赞 182 · 访问量 8640

猜你喜欢

转载自blog.csdn.net/qq_45645641/article/details/105411909