要编一个程序, 接受用户从键盘输入的文本行, 并将文本行中的每个字符替换成字母表(a-z和大写)中该字符后面的第13个字符
 列如:输入 Nice to meet you 就要输出 Avpr gb zrry lbh  
 哪位能给我点提示吗? 关于转换这一步.. 谢谢!!

解决方案 »

  1.   

    用ASCII码值来转换
    A-Z 65-90
    a-z 97-122newInt=((oldInt+13)-65)%26+65
      

  2.   

    把输入包装成bufferedreader当做字符串读取,在取出其中的每个加字符13输出,超过Z的再判断成回到A往后面加
      

  3.   

    以上式子是对于大写字母 如是小写
    newInt=((oldInt+13)-97)%26+97
      

  4.   


    import java.io.IOException;public class Test { public static void main(String[] args) {
    int in = 0;
    try {
    while ((in = System.in.read()) != 13) {
    if (in >= 65 && in <= 90) {
    System.out.print((char) (((in + 13) - 65) % 26 + 65));
    } else if (in >= 97 && in <= 122) {
    System.out.print((char) (((in + 13) - 97) % 26 + 97));
    } else {
    System.out.print((char) in);
    }
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    }}
    /*
     Input: Nice to meet you
    Output: Avpr gb zrrg lbh
    */
      

  5.   


    import java.io.FileWriter;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.*;public class Lx2 {
        public Lx2() {
        }    public static void main(String[] args) {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            try {
                FileWriter fw = new FileWriter("ww.txt");
                BufferedWriter bw = new BufferedWriter(fw);            while(true)
                {
                    System.out.println("> ");
                    StringBuffer line = new StringBuffer(br.readLine());
                    if(line != null && line.equals("quit"))
                    {
                        break;
                    }
                    bw.write(line.toString());
                    for(int i=0; i<line.length();i++)
                    {
                        System.out.println(line);
                    }                bw.newLine();
                }
            } catch (IOException ex) {
            }
        }
    }
      

  6.   


    import java.io.FileWriter;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.*;public class Lx2 {
        public Lx2() {
        }    public static void main(String[] args) {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            try {
                FileWriter fw = new FileWriter("ww.txt");
                BufferedWriter bw = new BufferedWriter(fw);            while(true)
                {
                    System.out.println("> ");
                    StringBuffer line = new StringBuffer(br.readLine());
                    if(line != null && line.equals("quit"))
                    {
                        break;
                    }
                    bw.write(line.toString());
                    for(int i=0; i<line.length();i++)
                    {
                        System.out.println(line);
                    }                bw.newLine();
                }
            } catch (IOException ex) {
            }
        }
    }