Opzione 1 "Mind size: **MEGAGIGA**"
This commit is contained in:
parent
97c65ade8e
commit
aaad7bb706
19
Program.cs
19
Program.cs
@ -24,10 +24,10 @@ class Program {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
if (Palindromo()) {
|
if (ParolaPalindroma()) {
|
||||||
Console.WriteLine("La parola è palindroma");
|
Console.WriteLine("La parola è palindroma");
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
Console.WriteLine("La parola non è palindroma");
|
Console.WriteLine("La parola non è palindroma");
|
||||||
}
|
}
|
||||||
Pausa();
|
Pausa();
|
||||||
@ -84,9 +84,10 @@ class Program {
|
|||||||
return p_array;
|
return p_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Palindromo() {
|
static bool ParolaPalindroma() {
|
||||||
string stringa;
|
string stringa;
|
||||||
bool ritorno;
|
bool ritorno;
|
||||||
|
char[] metà1, metà2;
|
||||||
do {
|
do {
|
||||||
Console.Write("Inserire una parola: ");
|
Console.Write("Inserire una parola: ");
|
||||||
stringa = Console.ReadLine().ToLower(); //convertita in minuscolo per identificare palindromi case insensitive
|
stringa = Console.ReadLine().ToLower(); //convertita in minuscolo per identificare palindromi case insensitive
|
||||||
@ -97,8 +98,16 @@ class Program {
|
|||||||
}
|
}
|
||||||
while (stringa.Contains(' '));
|
while (stringa.Contains(' '));
|
||||||
|
|
||||||
char[] metà1 = stringa.Substring(0, stringa.Length / 2).ToCharArray(); //divido la stringa a metà, prendo la prima e la converto in array di char per riordinarne le lettere
|
//la divisione serve per escludere la lettera che divide perfettamente a metà la parola con lettere dispari
|
||||||
char[] metà2 = stringa.Substring(stringa.Length/2, stringa.Length/2).ToCharArray(); //divido la stringa a metà, prendo la seconda e la converto in array di char per riordinarne le lettere
|
if (stringa.Length % 2 == 0) {
|
||||||
|
metà1 = stringa.Substring(0, stringa.Length / 2).ToCharArray(); //divido la stringa a metà, prendo la prima e la converto in array di char per riordinarne le lettere
|
||||||
|
metà2 = stringa.Substring(stringa.Length / 2, stringa.Length / 2).ToCharArray(); //divido la stringa a metà, prendo la seconda e la converto in array di char per riordinarne le lettere
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
metà1 = stringa.Substring(0, stringa.Length / 2).ToCharArray(); //divido la stringa a metà, prendo la prima e la converto in array di char per riordinarne le lettere
|
||||||
|
metà2 = stringa.Substring((stringa.Length / 2) + 1, stringa.Length / 2).ToCharArray(); //divido la stringa a metà, prendo la seconda e la converto in array di char per riordinarne le lettere
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string metàOrdinata1 = string.Join("", InsertionSort(metà1));//ordino la prima metà della stringa e la riconverto da array di char in stringa
|
string metàOrdinata1 = string.Join("", InsertionSort(metà1));//ordino la prima metà della stringa e la riconverto da array di char in stringa
|
||||||
string metàOrdinata2 = string.Join("", InsertionSort(metà2));//ordino la secondo metà della stringa e la riconverto da array di char in stringa
|
string metàOrdinata2 = string.Join("", InsertionSort(metà2));//ordino la secondo metà della stringa e la riconverto da array di char in stringa
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("strings_2")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("strings_2")]
|
||||||
[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+df4f2918a49cbd8aeeebe19777d71532803e253e")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+97c65ade8e1a0e7e912b959c732d32df692d42e4")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("strings_2")]
|
[assembly: System.Reflection.AssemblyProductAttribute("strings_2")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("strings_2")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("strings_2")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
// Generated by the MSBuild WriteCodeFragment class.
|
// Generato dalla classe WriteCodeFragment di MSBuild.
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
69f869a208dc09bd1be386fdbbafe9f6913df04b08dc4f24906dd6e708dc41ef
|
049a95f073c2bbaacb9a0f60962811b08e9cd32894ba1b07148583ce8cae646e
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user