算法竞赛入门经典的java实现之QWERTYU->Demo23.java
下面贴出源码:
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);
}
}