WERTYU

问题:
把手放在键盘上时,稍不注意就会往错一位。这样,输入q会变成输入w,输入j会变成输入k等。
输入一个错位后敲出的字符串(所有字母均小写),输出打字员本来想打出的句子。
ps. 输入保证合法,如果出现q、a、z的话则不变。

样例输入:
o s, gomr ypfsu/

样例输出:
i am fine today.

解:

public class Main{

	static char[] s = { 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
			'o', 'p', '[', ']', '\\', 'a', 's', 'd', 'f', 'g',
			'h', 'j', 'k', 'l', 'l', ';', '\'', 'z', 'x', 'c',
			'v', 'b', 'n', 'm', ',', '.', '/' };

	public static void main(String[] args) throws IOException {
		while (true) {
			char c = (char) System.in.read();
			if (c == '\r')
				break;
			if (c == ' ') {
				System.out.print(" ");
				continue;
			}
			int i = 0;
			while (s[i] != c) {
				i++;
				if (i == s.length)
					break;
			}
			if (c == 'q' || c == 'a' || c == 'z')
				i++;
			System.out.print(s[i - 1]);
		}
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值