El link del Problema se encuentra en el siguiente enlace
import java.util.Scanner;
/**
* 131A - cAPS lOCK - [http://www.codeforces.com]
*
* @author BreakDark
* @version 2.0 beta
*/
// ACEPTADO!!! xD
public class Main {
public static void main(String[] args) {
Scanner Lee;
String cadena;
byte i; // para bucles
// INICIA EL PROGRAMA
Lee = new Scanner(System.in);
while (Lee.hasNext()) {
cadena = Lee.next();
if (cadena.length() > 1) {
if ((cadena.equals(cadena.toUpperCase()))
|| (cadena.substring(1).equals(cadena.substring(1)
.toUpperCase()))) {
for (i = 0; i < cadena.length(); i++)
if (cadena.charAt(i) > 96 && cadena.charAt(i) < 123)
System.out.print((char) (cadena.charAt(i) - 32));
else
System.out.print((char) (cadena.charAt(i) + 32));
System.out.println();
} else
System.out.println(cadena);
} else {
if (cadena.charAt(0) >= 'a' && cadena.charAt(0) <= 'z')
System.out.println((char) (cadena.charAt(0) - 32));
else {
if (cadena.charAt(0) >= 'A' && cadena.charAt(0) <= 'Z')
System.out.println((char) (cadena.charAt(0) + 32));
else
System.out.println(cadena);
}
}
}
}
}
|
No comments:
Post a Comment