Reversal
时间限制:1秒 内存限制:128兆
258 次提交 138 次通过
-
题目描述
- You will get line with some words(only lowercase and uppercase, no other characters), input it and make all the word reversal and output. 输入
- The first line is a number T means there are T cases. For each case: The first line is N means next line has N words. All the words in a line and between two words only one blank. (No more than 100 words, and each word length not exceeded 10) 输出
- For each case, output a line with the reversal word in the input order. Between two words has exact one blank, but DO NOT output an blank at the end of a line. 样例输入
-
3 4 I am a man 4 I will AC it 3 I love ACM
样例输出 -
I ma a nam I lliw CA ti I evol MCA
提示 - 来源
- Zehua Hong
题意:将一句话中的单词倒着输出
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>
#include <functional>
using namespace std;
#define LL long long
const int INF=0x3f3f3f3f;
using namespace std;
int main()
{
int n,m;
char ch[105][20];
while(~scanf("%d",&n))
{
for(int i=0;i<n;i++)
{
scanf("%d",&m);
for(int j=0;j<m;j++)
scanf("%s",ch[j]);
for(int j=0;j<m-1;j++)
{
for(int k=strlen(ch[j])-1;k>=0;k--)
printf("%c",ch[j][k]);
printf(" ");
}
for(int k=strlen(ch[m-1])-1;k>=0;k--)
printf("%c",ch[m-1][k]);
printf("\n");
}
}
return 0;
}