From 9c272e12a72fd2699a5c25dfcebd58c6737cf9d0 Mon Sep 17 00:00:00 2001 From: Albert <87382668+alberrboyyy@users.noreply.github.com> Date: Fri, 7 Nov 2025 11:12:08 +0100 Subject: [PATCH] ajout du code de morse --- Couteau_Suisse/Morse.cs | 148 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Couteau_Suisse/Morse.cs diff --git a/Couteau_Suisse/Morse.cs b/Couteau_Suisse/Morse.cs new file mode 100644 index 0000000..bf30228 --- /dev/null +++ b/Couteau_Suisse/Morse.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Couteau_Suisse +{ + internal class Morse + { + static void Main(string[] args) + { + Console.WriteLine("=== Convertisseur de texte en code Morse ===\n" + + "Entrez un mot ou une phrase (sans accents, lettres A-Z) :"); + + char[] kilian = Console.ReadLine().ToCharArray(); + string theocable = ""; + + for (int i = 0; i < kilian.Length; i++) + { + switch (kilian[i]) + { + case 'a': + theocable += ".-"; + break; + case 'b': + theocable += "-..."; + break; + case 'c': + theocable += "-.-."; + break; + case 'd': + theocable += "-.."; + break; + case 'e': + theocable += "-."; + break; + case 'f': + theocable += "..-."; + break; + case 'g': + theocable += "--."; + break; + case 'h': + theocable += "...."; + break; + case 'i': + theocable += ".."; + break; + case 'j': + theocable += ".---"; + break; + case 'k': + theocable += "-.-"; + break; + case 'l': + theocable += ".-.."; + break; + case 'm': + theocable += "--"; + break; + case 'n': + theocable += "-."; + break; + case 'o': + theocable += "---"; + break; + case 'p': + theocable += ".--."; + break; + case 'q': + theocable += "--.-"; + break; + case 'r': + theocable += ".-."; + break; + case 's': + theocable += "..."; + break; + case 't': + theocable += "-"; + break; + case 'u': + theocable += "..u"; + break; + case 'v': + theocable += "...-"; + break; + case 'w': + theocable += ".--"; + break; + case 'x': + theocable += "-..-"; + break; + case 'y': + theocable += "-.--"; + break; + case 'z': + theocable += "--.."; + break; + case '0': + theocable += "-----"; + break; + case '1': + theocable += ".----"; + break; + case '2': + theocable += "..---"; + break; + case '3': + theocable += "...--"; + break; + case '4': + theocable += "....-"; + break; + case '5': + theocable += "....."; + break; + case '6': + theocable += "-...."; + break; + case '7': + theocable += "--..."; + break; + case '8': + theocable += "---.."; + break; + case '9': + theocable += "----."; + break; + case ' ': + theocable += "/"; + break; + + + default: + return; + } + theocable += " "; + } + + Console.WriteLine("\n" + + "Résultat en Morse :" + "\n" + + theocable); + } + + } +}