CAPS LOCKTime
limit:500MS
Memory Limit:262144KB
64bit IO Format:%i64d &%i64 U SubmitStatusPracticecodeforces 131A
Description
What does WE need CAPS LOCK for?
Caps Lock is a computer keyboard key. Pressing it sets an input mode in which typed letters is capital by default. If It is pressed by accident, it leads to accidents like the one we had in the first passage.
Let's consider that a word have been typed with the Caps lock key accidentally switched on, if:
- Either it only contains uppercase letters;
- or all letters except for the first one is uppercase.
In this case we should automatically, the case of all letters. For example, the case of the letters, which form words "HELLO", "HTTP", "Z" should be changed.
Write a program, that applies the rule mentioned above. If The rule cannot is applied, the program should leave the word unchanged.
Input
The first line of the input data contains a word consisting of uppercase and lowercase Latin letters. The word ' s length is from 1 to characters, inclusive.
Output
Print The result of the given word ' s processing.
Sample Input
Input
CAPS
Output
Caps
Input
Lock
Output
Lock
1#include <stdio.h>2#include <string.h>3 intMain ()4 {5 Chara[ the];6 inti,j,k;7 while(SCANF ("%s", a)! =EOF)8 {9 intflg=1;Ten intL=strlen (a); One for(i=1; i<l;i++) A { - if('A'<=a[i] && a[i]<='Z') -k=1; the Else - { -flg=0; - Break; + } - } + //printf ("%d\n", FLG); A if(flg!=1) atprintf"%s\n", a); - Else - { - if('A'<=a[0] && a[0]<='Z') -printf"%c", a[0]+ +); - Else inprintf"%c", a[0]- +); - for(i=1; i<l;i++) toprintf"%c", a[i]+ +); + } -printf"\ n"); the } * return 0; $}
View Code
Codeforces 131A CAPS LOCK