您好 这个好像不是一个完整的句子哦 翻译为:
THENETTTGET
以下是摩斯密码表 您可以再看一下
摩斯密码表
望采纳 谢谢
import java.util.*;
class Demo
{
public static void main(String[] args)
{
String s1 = "../.━../━ ━ ━/...━/./━.━ ━/━ ━ ━/..━";
String s2 = "ILOVEYOU";
method_1(s1);
method_2(s2);
}
public static void method_1(String s)//执行摩斯码转换字母
{
String[] st = s.split("/");
HashMapString,String hm = new HashMapString,String();
hm.put(".━","A");
hm.put("━...","B");
hm.put("━ .━.","C");
hm.put("━ ..","D");
hm.put(".","E");
hm.put("..━.","F");
hm.put("━ ━.","G");
hm.put("....","H");
hm.put("..","I");
hm.put(".━ ━ ━","J");
hm.put("━ .━","K");
hm.put(".━..","L");
hm.put("━ ━","M");
hm.put("━.","N");
hm.put("━ ━ ━","O");
hm.put(".━ ━.","P");
hm.put("━ ━.━","Q");
hm.put(".━ .","R");
hm.put("...","S");
hm.put("━","T");
hm.put("..━","U");
hm.put("...━","V");
hm.put(".━ ━","W");
hm.put("━ ..━","X");
hm.put("━.━ ━","Y");
hm.put("━ ━ ..","Z");
for(int x=0;xst.length;x++)
{
System.out.print(hm.get(st[x]));
}
}
public static void method_2(String s)//执行字母转换摩斯码
{
String st = s.toUpperCase();
char[] buf = st.toCharArray();
HashMapString,String hm = new HashMapString,String();
hm.put("A",".━");
hm.put("B","━...");
hm.put("C","━ .━.");
hm.put("D","━ ..");
hm.put("E",".");
hm.put("F","..━.");
hm.put("G","━ ━.");
hm.put("H","....");
hm.put("I","..");
hm.put("J",".━ ━ ━");
hm.put("K","━ .━");
hm.put("L",".━..");
hm.put("M","━ ━");
hm.put("N","━.");
hm.put("O","━ ━ ━");
hm.put("P",".━ ━.");
hm.put("Q","━ ━.━");
hm.put("R",".━ .");
hm.put("S","...");
hm.put("T","━");
hm.put("U","..━");
hm.put("V","...━");
hm.put("W",".━ ━");
hm.put("X","━ ..━");
hm.put("Y","━.━ ━");
hm.put("Z","━ ━ ..");
for(int x=0;xbuf.length;x++)
{
System.out.print(hm.get(buf[x]+""));
System.out.print("/");
}
}
}
以上代码可执行摩斯码---字母的双向转换,我在代码中给摩斯码加了分隔号,这样易于观看。亲,我做任务不容易呀~~!!求好评
Mid(Temp, i, 1) = GetUserCar(Mid(UserInStr, i, 1))
这句很奇怪,不是条件表达式的话赋值语句没有这么做的
另外里面的1是截取1位,输出缺要两位,你想想
定义函数如下:
def get_code_list(unit_list):return [[''.join('s' if e=='1' else 'L' for e in s.split('0')) for s in l] for l in unit_list]
可能没有get到你的点,也可能没有在意,更可能是不想理会;建议你可以再直接一点。
定义函数如下:
def get_sentence(code_list):return ' '.join(''.join(morse2char[e] for e in l) for l in code_list)