TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
- 摩尔码,以前的电报码,也许这个程序没有多大意义,但是可以用来回忆过去的
- 军事和通讯生活。电报是怎么做出来的呢?呵呵。看了就明白了。
- // Name: Fubin My Msn:yonghe169@163.com
- import java.io.*;
- import java.util.*;
- class MorseCoder{
- public static void main(String [] args) throws IOException{
- BufferedReader stdin = new BufferedReader
- (new InputStreamReader(System.in));
- System.out.println();
- System.out.println();
- System.out.println("**************************************************");
- System.out.println();
- System.out.println(" MORSE-CODE CODER ");
- System.out.println("");
- System.out.println();
- System.out.println("A Program designed by Ali Ezad Abbas");
- System.out.println(" Deptt. of Electrical Engineering, UET, Lahore");
- System.out.println();
- System.out.println("***************************************************");
- System.out.println();
- System.out.println();
- System.out.print("Please enter the string to be coded (small alphabets): ");
- String word = stdin.readLine();
- StringTokenizer words = new StringTokenizer(word," ",true);
- String output = "";
- String temp = "";
- while(words.hasMoreTokens()){
- String nerd = words.nextToken();
- StringBuffer sos = new StringBuffer(nerd);
- int len = sos.length();
- for(int i=0;i< len;i++){
- char input = sos.charAt(i);
- if(input=="a"){
- temp = ".-";
- }
- if(input=="b"){
- temp = "-...";
- }
- if(input=="c"){
- temp = "-.-.";
- }
- if(input=="d"){
- temp = "-..";
- }
- if(input=="e"){
- temp = ".";
- }
复制代码
********************************************************** MORSE-CODE CODER
A Program designed by Ali Ezad Abbas
Deptt. of Electrical Engineering, UET, Lahore **********************************************************
Please enter the string to be coded (small alphabets): hello how are you
The coded sentence is:
.... . .-.. .-.. --- .... --- .-- .- .-. . -.-- --- ..- C:work>
源码下载:http://file.javaxxz.com/2014/10/2/021152703.zip |
|