diff --git a/Program.cs b/Program.cs index 19ed946..2673b5a 100644 --- a/Program.cs +++ b/Program.cs @@ -34,7 +34,7 @@ class Program { break; case 4: Console.Clear(); - + LetterSwap(); Pausa(); break; default: @@ -105,7 +105,7 @@ class Program { return ritorno; } - static void Submenu(){ + static void Submenu() { Console.Clear(); string frase, input; int scelta; @@ -122,7 +122,7 @@ class Program { Console.WriteLine("1. Converti in minuscolo"); Console.WriteLine("2. Converti in maiuscolo"); Console.WriteLine("3. Sostituisci \'.\' con \\n"); - Console.WriteLine("0. Esci"); + Console.WriteLine("0. Torna al menù precedente"); Console.Write("Scelta: "); scelta = Convert.ToInt32(Console.ReadLine()); @@ -158,4 +158,42 @@ class Program { } while (scelta != 0); } + + static void LetterSwap() { + string input, stringa1, stringa2, stringa3; + int numeroLettere, i, j = 0; + + Console.Write("Inserire una frase: "); + input = Console.ReadLine(); + Console.Write("Inserire il numero di lettere da scambiare: "); + numeroLettere = Convert.ToInt32(Console.ReadLine()); + + + char[] array1 = new char[numeroLettere]; + char[] array2 = new char[input.Length - numeroLettere * 2]; + char[] array3 = new char[numeroLettere]; + + for (i = 0; i < numeroLettere; i++) { + array1[j] = input[i]; + j++; + } + + stringa1 = string.Join("", array1); + + j = 0; + for (; i < input.Length - numeroLettere; i++) { + array2[j] = input[i]; + j++; + } + stringa2 = string.Join("", array2); + + j = 0; + for (; i < input.Length; i++) { + array3[j] = input[i]; + j++; + } + stringa3 = string.Join("", array3); + + Console.WriteLine($"La frase con le lettere scambiate è: {stringa3}{stringa2}{stringa1}"); + } } diff --git a/bin/Debug/net9.0/strings_1.dll b/bin/Debug/net9.0/strings_1.dll index 462270c..59e027a 100644 Binary files a/bin/Debug/net9.0/strings_1.dll and b/bin/Debug/net9.0/strings_1.dll differ diff --git a/bin/Debug/net9.0/strings_1.pdb b/bin/Debug/net9.0/strings_1.pdb index 3ec9fdf..6f00e0b 100644 Binary files a/bin/Debug/net9.0/strings_1.pdb and b/bin/Debug/net9.0/strings_1.pdb differ diff --git a/obj/Debug/net9.0/ref/strings_1.dll b/obj/Debug/net9.0/ref/strings_1.dll index 0daa1d3..70e8ae3 100644 Binary files a/obj/Debug/net9.0/ref/strings_1.dll and b/obj/Debug/net9.0/ref/strings_1.dll differ diff --git a/obj/Debug/net9.0/refint/strings_1.dll b/obj/Debug/net9.0/refint/strings_1.dll index 0daa1d3..70e8ae3 100644 Binary files a/obj/Debug/net9.0/refint/strings_1.dll and b/obj/Debug/net9.0/refint/strings_1.dll differ diff --git a/obj/Debug/net9.0/strings_1.AssemblyInfo.cs b/obj/Debug/net9.0/strings_1.AssemblyInfo.cs index b800bb9..b0df734 100644 --- a/obj/Debug/net9.0/strings_1.AssemblyInfo.cs +++ b/obj/Debug/net9.0/strings_1.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("strings_1")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+31b87989795cdfc8100c8dabff5d2ce0a03e2e16")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ccf2dfdddbb4c94a19e023f37e05913e2545cff7")] [assembly: System.Reflection.AssemblyProductAttribute("strings_1")] [assembly: System.Reflection.AssemblyTitleAttribute("strings_1")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net9.0/strings_1.AssemblyInfoInputs.cache b/obj/Debug/net9.0/strings_1.AssemblyInfoInputs.cache index dc3e843..e14dedc 100644 --- a/obj/Debug/net9.0/strings_1.AssemblyInfoInputs.cache +++ b/obj/Debug/net9.0/strings_1.AssemblyInfoInputs.cache @@ -1 +1 @@ -260a48af17a58db4c14ce60e5b496bd92beb2181e1f61cd574e399e1f1445cf0 +d4a8bf2719c6ab479c0f2d6052891a9062b0f984718d04ce460f7e151ca9bbeb diff --git a/obj/Debug/net9.0/strings_1.dll b/obj/Debug/net9.0/strings_1.dll index 462270c..59e027a 100644 Binary files a/obj/Debug/net9.0/strings_1.dll and b/obj/Debug/net9.0/strings_1.dll differ diff --git a/obj/Debug/net9.0/strings_1.pdb b/obj/Debug/net9.0/strings_1.pdb index 3ec9fdf..6f00e0b 100644 Binary files a/obj/Debug/net9.0/strings_1.pdb and b/obj/Debug/net9.0/strings_1.pdb differ