Problem Statement
You are given �N strings �1,�2,…,��S1,S2,…,SN按此顺序。
按此顺序打印。��,��−1,…,�1SN,SN−1,…,S1
约束
- 1≤�≤101≤N≤10
- �N is an integer.
- ��Si is a string of length between 11 and 1010, inclusive, consisting of lowercase English letters, uppercase English letters, and digits.
Input
The input is given from Standard Input in the following format:
�N
�1S1
�2S2
⋮⋮
��SN
Output
Print �N lines. The �i-th (1≤�≤�)(1≤i≤N) line should contain ��+1−�SN+1−i.
Sample 1
Inputcopy | Outputcopy |
---|---|
3 Takahashi Aoki Snuke | Snuke Aoki Takahashi |
We have �=3N=3, �1=S1= Takahashi
, �2=S2= Aoki
, and �3=S3= Snuke
.
Thus, you should print Snuke
, Aoki
, and Takahashi
in this order.
Sample 2
Inputcopy | Outputcopy |
---|---|
4 2023 Year New Happy | Happy New Year 2023 |
The given strings may contain digits.
题解:
1:创建一个二维数组;记录它的序号和字符串。
2:倒序输出
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[100][100];
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
getchar();
for(int i=n-1;i>=0;i--)
cout<<a[i]<<endl;
}