#C9019. Toggle Case Conversion
Toggle Case Conversion
Toggle Case Conversion
You are given a string s. Your task is to convert each alphabetical character in the string to its opposite case. Specifically, every lowercase letter should become uppercase and every uppercase letter should become lowercase. Non-alphabetical characters should remain unchanged.
Input/Output Format:
The program reads input from stdin
and outputs the result to stdout
. The input consists of a single line that contains the string. The output should be a single line containing the toggled case string.
Example:
- If the input is:
Hello, World!
- The output should be:
hELLO, wORLD!
In mathematical terms, if we define a function \( f: \Sigma^* \to \Sigma^* \) where \( \Sigma \) is the set of ASCII characters, then for each character \( c \) in the input string \( s \), the output is given by:
\[ f(c) = \begin{cases} \text{toUpperCase}(c) & \text{if } c \text{ is lowercase}\\ \text{toLowerCase}(c) & \text{if } c \text{ is uppercase}\\ c & \text{if } c \text{ is non-alphabetical} \end{cases} \]
inputFormat
The input consists of a single line containing a string s
that may include letters, digits, spaces, and special characters.
For example: Hello, World!
outputFormat
The output is a single line containing the transformed string where the case of each alphabetical character from the input is toggled.
For example, for the input Hello, World!
, the output should be hELLO, wORLD!
.
Hello, World!
hELLO, wORLD!