hdu 2140 java 代码哪里错了一直都是WA?
题目网址:【http://acm.hdu.edu.cn/showproblem.php?pid=2140】importjava.util.*;publicclassMai...
题目网址:【http://acm.hdu.edu.cn/showproblem.php?pid=2140】
import java.util.*;
public class Main{
static char trans(char c){
switch(c){
case 'b':return ' ';
case 'q':return ',';
case 't':return '!';
case 'm':return 'l';
case 'i':return 'e';
case 'c':return 'a';
case 'e':return 'i';
case 'l':return 'm';
default:return c;
}
}
public static void main(String []args){
Scanner in = new Scanner(System.in);
while(in.hasNext()){
String s = in.nextLine();
for(int i=0;i<s.length();i++){
char c = s.charAt(i);
System.out.print(trans(c));
}
System.out.println();
}
}
} 展开
import java.util.*;
public class Main{
static char trans(char c){
switch(c){
case 'b':return ' ';
case 'q':return ',';
case 't':return '!';
case 'm':return 'l';
case 'i':return 'e';
case 'c':return 'a';
case 'e':return 'i';
case 'l':return 'm';
default:return c;
}
}
public static void main(String []args){
Scanner in = new Scanner(System.in);
while(in.hasNext()){
String s = in.nextLine();
for(int i=0;i<s.length();i++){
char c = s.charAt(i);
System.out.print(trans(c));
}
System.out.println();
}
}
} 展开
展开全部
import java.util.*;
public class Main {
static char trans(char c) {
switch (c) {
case 'b': return ' ';
case 'q': return ',';
case 't': return '!';
case 'm': return 'l';
case 'i': return 'e';
case 'c': return 'a';
case 'a': return 'c'; // 漏了这一个
case 'e': return 'i';
case 'l': return 'm';
default: return c;
}
}
public static void main(String[]args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String s = in.next();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
System.out.print(trans(c));
}
System.out.println();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询