Reverse Word Order
Time limit5sMemory limit512 MB
Given N lines of space-separated words, print each line's words in reverse order prefixed with the case number.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
You are given lists of words separated by spaces, one list per line. Print the words of each line in reverse order.
A line holds English words and letters in total. Each line contains only letters and spaces, and exactly one space separates two neighboring words.
Input
The first line contains , the number of cases.
Each of the next lines is one case and holds words separated by spaces. No line starts or ends with a space.
Output
Print one line per case. For case number , print Case #x: first, then the words of that line in reverse order, separated by one space.