題解1249:簡單編碼 (Java描述)

acDream_發表於2018-06-22

解題思路:





注意事項:





參考程式碼:

Scanner in = new Scanner(System.in);

String bm;

StringBuffer bmBuffer;

while(in.hasNext()) {

bm=in.next();

bmBuffer = new StringBuffer(bm);

if(bm.equals("END")) {

break;

}

else {

for(int i=0;i<bmBuffer.length();i++) {

switch(bmBuffer.charAt(i)) {

case 'A':

case 'W':

case 'F':

bmBuffer.setCharAt(i, 'I');

break;

case 'C':

bmBuffer.setCharAt(i, 'L');

break;

case 'M':

bmBuffer.setCharAt(i, 'o');

break;

case 'S':

bmBuffer.setCharAt(i, 'v');

break;

case 'D':

case 'P':

case 'G':

case 'B':

bmBuffer.setCharAt(i, 'e');

break;

case 'L':

bmBuffer.setCharAt(i, 'Y');

break;

case 'X':

bmBuffer.setCharAt(i, 'u');

break;

}

}

System.out.println(bmBuffer);

}

}


相關文章