“Kode Java ke Python Converter Online” Kode Jawaban

Kode Java ke Python Converter Online

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Morse {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        try (PrintWriter saida = new PrintWriter("morse.out")) {
            BufferedReader entrada;

            entrada = new BufferedReader(new FileReader("morse.in"));

            String linha;
            String morse[] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....",
                "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",
                "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."};

            while ((linha = entrada.readLine()) != null) {
                String temp[] = linha.split(" ");
                int cont;
                String palavra = "";
                for (String t : temp) {
                    cont = 0;
                    for (String p : morse) {
                        if (t.equals(p)) {
                            palavra += (char) (65 + cont);
                            break;
                        }
                        cont++;
                    }
                }
                saida.println(palavra);
                if (linha.equals("..-. .. --")) {
                    break;
                }
            }
            entrada.close();
            saida.close();
        }
    }
}

Disturbed Dolphin

Kode Java ke Python Converter Online

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Morse {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        try (PrintWriter saida = new PrintWriter("morse.out")) {
            BufferedReader entrada;

            entrada = new BufferedReader(new FileReader("morse.in"));

            String linha;
            String morse[] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....",
                "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",
                "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."};

            while ((linha = entrada.readLine()) != null) {
                String temp[] = linha.split(" ");
                int cont;
                String palavra = "";
                for (String t : temp) {
                    cont = 0;
                    for (String p : morse) {
                        if (t.equals(p)) {
                            palavra += (char) (65 + cont);
                            break;
                        }
                        cont++;
                    }
                }
                saida.println(palavra);
                if (linha.equals("..-. .. --")) {
                    break;
                }
            }
            entrada.close();
            saida.close();
        }
    }
}
Disturbed Dolphin

Jawaban yang mirip dengan “Kode Java ke Python Converter Online”

Pertanyaan yang mirip dengan “Kode Java ke Python Converter Online”

Lebih banyak jawaban terkait untuk “Kode Java ke Python Converter Online” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya