close
題目概要:
W以Q表示、E以W表示...以此類推。
解題方向:
建立一個table存放鍵盤上所有值,把輸入的字串拆成字元一個一個跟table做比較,找出相同字元的index,輸出table[index-1]即可是答案。
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Java | |
import java.util.Scanner; | |
class uva10082{ | |
public static void main(String args[]){ | |
Scanner sc=new Scanner(System.in); | |
String table="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; | |
while(sc.hasNextLine()){ | |
String st=sc.nextLine(); | |
for(int i=0;i<st.length();i++){ | |
if(st.charAt(i)==' ') System.out.print(" "); | |
for(int j=0;j<table.length();j++){ | |
if(table.charAt(j)==st.charAt(i)){ | |
System.out.print(table.charAt(j-1)); | |
break; | |
} | |
} | |
} | |
System.out.println(""); | |
} | |
} | |
} |
文章標籤
全站熱搜