- import java.util.Scanner;
- public class JPA01 {
- String s;
- char first,last;
- int pass;
- Scanner sc=new Scanner(System.in);
- JPA01()
- {
- s=sc.next();
- if(s.length()==1){
- first=f(s.charAt(0));
- if(pass==1)
- System.out.println(first);
- else
- System.out.println("error");
- }
- else{
- first=f(s.charAt(0));
- last=f(s.charAt(s.length()-1));
- if(pass==1)
- {
- System.out.print(first);
- for(int i=1;i<s.length()-1;i++)
- System.out.print(s.charAt(i));
- System.out.println(last);
- }
- else
- System.out.println("error");
- }
-
- }
- char f(char s) {
- pass=1;
- if(s<58&&s>47){
- s++;
- if(s==58)
- s=48;
- }
- else if(s>64&&s<91)
- s+=33;
- else if(s>96&&s<123)
- s-=31;
- else
- pass=0;
- return s;
- }
- public static void main(String[] args) {
- new JPA01();
- }
- }
複製代碼 |