ajout du code de morse

This commit is contained in:
Albert 2025-11-07 11:12:08 +01:00
parent ecb47b4a12
commit 9c272e12a7

148
Couteau_Suisse/Morse.cs Normal file
View File

@ -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);
}
}
}