沒有翻譯軟件,但是能編寫翻譯程序。
java 代碼翻譯實例:
1.輸入壹個以’@’結束的字符串,從左至右翻譯。若下壹個字符是數字n(0≤n≤9),表示後壹個字符重復n+1 次,不論後壹個字符是否為數字;若下壹個字符非數字,則表示自己。
2.翻譯後,以3 個字符為壹組輸出,組與組之間用空格分開。
例如’A2B5E34FG0ZYWPQ59R@’,翻成’ABB_BEE_EEE_E44_44F_GZY_WPQ_999_999_R@ ’。
3.分析:首先直接遍歷數組把字符串按要求進行翻譯,然後將翻譯後的字符串進行分組形成字符串數組,最後把字符串數組用下劃線連接輸出。
java翻譯源代碼:
import java.util.Scanner;
public class Main5{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
int length = s.length();
String result = "";
char[] str = new char[length]
for (int i = 0; i < length; i++) {
str[i] = s.charAt(i);
}
result += str[0];
if (str[length - 1] != '@') {
System.out.println("輸入有誤!");
} else {
for (int index = 0; index < length - 1;) {
if ('0' == str[index + 1] || '1' == str[index + 1] || '2' == str[index + 1] || '3' == str[index + 1]
|| '4' == str[index + 1] || '5' == str[index + 1] || '6' == str[index + 1]
|| '7' == str[index + 1] || '8' == str[index + 1] || '9' == str[index + 1]) {
for (int i = 0; i < ((Integer.parseInt(str[index + 1]+"")) + 1); i++) {
result += str[index + 2];
}
index += 2;
} else {
result += str[index + 1];
index++;
}
}
}
System.out.println(getGroup(result));
}
//每3個分壹組
public static String getGroup(String s){
String[] r;
if(s.length()%3 == 0){
r = new String[s.length()/3];
}else{
r = new String[s.length()/3+1];
}
String result = "";
int j = 0;
for(int i=0;i<s.length();){
if(i+3 <= s.length()){
r[j]=s.substring(i, i+3);
j++;
i += 3;
}else{
r[j] = s.substring(i);
j++;
i += 3;
}
}
for(int i=0;i<r.length-1;i++){
result += (r[i]+"_");
}
result += r[r.length-1];
return result;
}
}