Opzione 5 + linting + valori prod CreaArrayCasuale + adeguamento 3 consecutivi

This commit is contained in:
La Programmatrice Verde 2024-12-27 10:56:48 +01:00
parent dff4366e30
commit 8a3aaf0afa
9 changed files with 53 additions and 37 deletions

View File

@ -44,9 +44,7 @@ class Program
break; break;
case 4: case 4:
Console.Clear(); Console.Clear();
array = CreaArrayCasuale(); if(TreConsecutivi(CreaArray()) == true){
StampaArray(array);
if(TreConsecutivi(array)==true){
Console.WriteLine("Tre valori consecutivi uguali"); Console.WriteLine("Tre valori consecutivi uguali");
} }
else{ else{
@ -56,6 +54,12 @@ class Program
break; break;
case 5: case 5:
Console.Clear(); Console.Clear();
if(DoppioDellAltro(CreaArrayCasuale()) == true){
Console.WriteLine("Doppio uno dell'altro");
}
else{
Console.WriteLine("NO");
}
Pausa(); Pausa();
break; break;
default: default:
@ -94,7 +98,7 @@ class Program
int[] ritorno = new int[dimensione]; int[] ritorno = new int[dimensione];
for(int i=0; i<dimensione; i++){ for(int i=0; i<dimensione; i++){
ritorno[i]=caso.Next(1, 4);//sostituire 1, 4 con Int32.MinValue, Int32.MaxValue quando è pronto tutto ritorno[i]=caso.Next(Int32.MinValue, Int32.MaxValue);
} }
return ritorno; return ritorno;
} }
@ -157,28 +161,23 @@ class Program
int i = 0, j = 0; int i = 0, j = 0;
while(consecutivo1==false && i<dimensione){ while(consecutivo1==false && i<dimensione){
Console.WriteLine("Ciclo " +i);
while(consecutivo1==false && j<dimensione){ while(consecutivo1==false && j<dimensione){
if (p_array[j] == p_array[i]+1){ if (p_array[j] == p_array[i]+1){
consecutivo1 = true; consecutivo1 = true;
} }
Console.WriteLine("j1: " + j);
j++; j++;
} }
j = 0; j = 0;
Console.WriteLine("i1: " + i);
i++; i++;
} }
i = 0; i = 0;
j = 0; j = 0;
if(consecutivo1 == true){ if(consecutivo1 == true){
while(consecutivo2==false && i<dimensione){ while(consecutivo2==false && i<dimensione){
Console.WriteLine("Ciclo consecutivo 2 " +i);
while(consecutivo2==false && j<dimensione){ while(consecutivo2==false && j<dimensione){
if (p_array[j] == p_array[i]+2){ if (p_array[j] == p_array[i]+2){
consecutivo2 = true; consecutivo2 = true;
} }
Console.WriteLine("j2: " + j);
j++; j++;
} }
j = 0; j = 0;
@ -193,4 +192,21 @@ class Program
} }
return ritorno; return ritorno;
} }
static bool DoppioDellAltro(int[] p_array){
bool ritorno = false;
int i = 0, j = 0;
while(ritorno==false && i<dimensione){
while(ritorno==false && j<dimensione){
if (p_array[j] == p_array[i]*2){
ritorno = true;
}
j++;
}
j = 0;
i++;
}
return ritorno;
}
} }

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("array_funzioni_4")] [assembly: System.Reflection.AssemblyCompanyAttribute("array_funzioni_4")]
[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+b70a39dbbe016d865b62ce029ba12d18862a7571")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+dff4366e30e266315f0fd967ab16d8509d629273")]
[assembly: System.Reflection.AssemblyProductAttribute("array_funzioni_4")] [assembly: System.Reflection.AssemblyProductAttribute("array_funzioni_4")]
[assembly: System.Reflection.AssemblyTitleAttribute("array_funzioni_4")] [assembly: System.Reflection.AssemblyTitleAttribute("array_funzioni_4")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
f8370efddee368823d742b2ce2af326cf9b4cbae328191ebab7352ed114ee1ba ca299e75237115b1e692d48d36398c1c127ee21df577772c1d66b6dd45a45494