From 70e2bb324b2c94fefbc53c8fb247bf1fe31c4a03 Mon Sep 17 00:00:00 2001 From: La Programmatrice Verde Date: Thu, 27 Feb 2025 10:18:21 +0100 Subject: [PATCH] Importata funzione per la codifica --- Program.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Program.cs b/Program.cs index 54c32ce..375f428 100644 --- a/Program.cs +++ b/Program.cs @@ -111,4 +111,35 @@ class Program { return p_array[maxIndex]; } + + static string Codifica() { + string stringa = Input(); + char codice = 'f'; + const char inutile = '\\'; + char[] ritorno = new char[stringa.Length * 2]; + Array.Fill(ritorno, inutile); + char[] vocali = { 'a', 'e', 'i', 'o', 'u' }; + int k = 0; + + + for (int i = 0; i < stringa.Length; i++) { + ritorno[k] = stringa[i]; + for (int j = 0; j < vocali.Length; j++) { + if (stringa[i] == vocali[j]) { + k++; + ritorno[k] = codice; + break; + } + else if (stringa[i] == char.ToUpper(vocali[j])) { + k++; + ritorno[k] = char.ToUpper(codice); + break; + } + } + k++; + + } + + return string.Join("", ritorno).Split(inutile).First(); + } } \ No newline at end of file