我改了一下:
import java.io.*;   public class ROT13 {
    public static void main(String[] args) throws IOException {
        
        BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
       
        String current=stdin.readLine();
        int l=current.length();
        int i=0;
        char c=current.charAt(i);    
        for(i=0;i<l;i++) {
         boolean flag=false;
            while(c>=65&&c<=77||(c>=97&&c<=109)) {
            c+=13;
            System.out.print(c);
flag=true;
break;
            }
if(!flag){
             while(c>77&&c<=90||(c>109&&c<=122)) {
             c-=13;
             System.out.print(c); 
             break; 
             }
            }
        }    }
}

解决方案 »

  1.   

    哦,你说的问题我以后会注意的。
    刚开始学JAVA,不懂的东西很多,以后还请多多关照啊~怎样把int转成char?一直不清楚。
      

  2.   

    好了,现在差不多了:
    import java.io.*;   public class ROT13 {
        public static void main(String[] args) throws IOException {
            
            BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
           
            String current=stdin.readLine();
            int l=current.length();
            char c;    
            for(int i=0;i<l;i++) {
             c=current.charAt(i);
                if(c>=65&&c<=77||(c>=97&&c<=109)) {
                c+=13;
                System.out.print(c);
                }
                else if(c>77&&c<=90||(c>109&&c<=122)) {
                c-=13;
                System.out.print(c);             
                }
                else 
                System.out.print(c);
            }    }
    }
      

  3.   

    对了,我在for里面用while就没有必要,而且对非字母的情况也没有处理。
    谢谢!
      

  4.   

    我的做法也差不多。import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;public class Rot13 { public static void main(String[] args) {
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    try {
    String str = bf.readLine();
    for(int i = 0 ; i< str.length() ; i++) {
    char c = str.charAt(i);
    if (c >= 'a' && c <='m' || c >= 'A' && c <= 'M') {
    c += 13;
    System.out.print(c);
    } else if(c >= 'n' && c <= 'z' || c >='N' && c <= 'Z' ) {
    c -= 13;
    System.out.print(c);
    }
    }

    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
      

  5.   

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;public class Rot13 {    public static void main(String[] args) {
            BufferedReader bf =
                new BufferedReader(new InputStreamReader(System.in));
            try {
                String str = bf.readLine();
                for (int i = 0; i < str.length(); i++) {
                    char c = str.charAt(i);
                    if (c >= 'a' && c <= 'm' || c >= 'A' && c <= 'M') {
                        c += 13;
                        System.out.print(c);
                    } else if (c >= 'n' && c <= 'z' || c >= 'N' && c <= 'Z') {
                        c -= 13;
                        System.out.print(c);
                    }
                }        } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }