HDU1062 - Text Reverse
文章目录
链接:https://vjudge.net/problem/HDU-1062
Task
Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single line with several words. There will be at most 1000 characters in a line.
Output
For each test case, you should output the text which is processed.
Sample
input:
|
|
output:
|
|
Solution
将一句话中被空格分开的字符串们反序,用栈。未读到空格或换行或结束符时,向栈中压入字符。读到空格或换行或结束符时一次性弹出栈中所有字符,特别地,读到换行或结束符时跳出一次循环。
注意输入每一行时用getchar()
等待输入,否则会乱
|
|