Opzione 4
This commit is contained in:
parent
ccf2dfdddb
commit
ef6982364c
44
Program.cs
44
Program.cs
@ -34,7 +34,7 @@ class Program {
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
|
LetterSwap();
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -105,7 +105,7 @@ class Program {
|
|||||||
return ritorno;
|
return ritorno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Submenu(){
|
static void Submenu() {
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
string frase, input;
|
string frase, input;
|
||||||
int scelta;
|
int scelta;
|
||||||
@ -122,7 +122,7 @@ class Program {
|
|||||||
Console.WriteLine("1. Converti in minuscolo");
|
Console.WriteLine("1. Converti in minuscolo");
|
||||||
Console.WriteLine("2. Converti in maiuscolo");
|
Console.WriteLine("2. Converti in maiuscolo");
|
||||||
Console.WriteLine("3. Sostituisci \'.\' con \\n");
|
Console.WriteLine("3. Sostituisci \'.\' con \\n");
|
||||||
Console.WriteLine("0. Esci");
|
Console.WriteLine("0. Torna al menù precedente");
|
||||||
Console.Write("Scelta: ");
|
Console.Write("Scelta: ");
|
||||||
scelta = Convert.ToInt32(Console.ReadLine());
|
scelta = Convert.ToInt32(Console.ReadLine());
|
||||||
|
|
||||||
@ -158,4 +158,42 @@ class Program {
|
|||||||
}
|
}
|
||||||
while (scelta != 0);
|
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}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("strings_1")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("strings_1")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[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.AssemblyProductAttribute("strings_1")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("strings_1")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("strings_1")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
260a48af17a58db4c14ce60e5b496bd92beb2181e1f61cd574e399e1f1445cf0
|
d4a8bf2719c6ab479c0f2d6052891a9062b0f984718d04ce460f7e151ca9bbeb
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user