版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36737934/article/details/80208995
下面贴出源码:
package cn.zimo.algorithm;
import java.util.Scanner;
/**
* WERTYU
* @author 子墨
* @date 2018年5月5日 下午7:56:47
*/
public class Demo23 {
public static void main(String[] args) {
String str=new Scanner(System.in).nextLine();
char[] temp = new char[str.length()];
String words = "1234567890-=QWERTYUIOP[]ASDFGHJKL;'\\ZXCVBNM,./";
for(int i = 0;i < str.length(); i++) {
if(str.charAt(i) != ' ') {
temp[i]=words.toCharArray()[words.indexOf(str.charAt(i))-1];
}
}
System.out.println(temp);
}
}