#C12202. Reverse Words Order and Swap Cases
Reverse Words Order and Swap Cases
Reverse Words Order and Swap Cases
You are given a string consisting of one or more words separated by spaces. Your task is to reverse the order of the words and swap the case of each alphabetical character. For example, if the input string is Hello World
, the expected output is wORLD hELLO
.
Swapping the case means converting each uppercase letter to lowercase and each lowercase letter to uppercase.
The problem can be summarized as follows:
Given a string \(S\), let its words be \(w_1, w_2, ..., w_n\). You need to produce a string \(S'\) such that \(S' = swapcase(w_n) + \ " " + swapcase(w_{n-1}) + \ ... + \ " " + swapcase(w_1)\), where swapcase
changes the letter case.
inputFormat
The input consists of a single line containing a string \(S\) composed of words separated by spaces.
outputFormat
Output a single line which is the string with the order of words reversed and the case of each letter swapped.
## sampleHello World
wORLD hELLO