Opzione 5 + linting + valori prod CreaArrayCasuale + adeguamento 3 consecutivi
This commit is contained in:
parent
dff4366e30
commit
8a3aaf0afa
34
Program.cs
34
Program.cs
@ -44,9 +44,7 @@ class Program
|
||||
break;
|
||||
case 4:
|
||||
Console.Clear();
|
||||
array = CreaArrayCasuale();
|
||||
StampaArray(array);
|
||||
if(TreConsecutivi(array)==true){
|
||||
if(TreConsecutivi(CreaArray()) == true){
|
||||
Console.WriteLine("Tre valori consecutivi uguali");
|
||||
}
|
||||
else{
|
||||
@ -56,6 +54,12 @@ class Program
|
||||
break;
|
||||
case 5:
|
||||
Console.Clear();
|
||||
if(DoppioDellAltro(CreaArrayCasuale()) == true){
|
||||
Console.WriteLine("Doppio uno dell'altro");
|
||||
}
|
||||
else{
|
||||
Console.WriteLine("NO");
|
||||
}
|
||||
Pausa();
|
||||
break;
|
||||
default:
|
||||
@ -94,7 +98,7 @@ class Program
|
||||
int[] ritorno = new int[dimensione];
|
||||
|
||||
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;
|
||||
}
|
||||
@ -157,28 +161,23 @@ class Program
|
||||
int i = 0, j = 0;
|
||||
|
||||
while(consecutivo1==false && i<dimensione){
|
||||
Console.WriteLine("Ciclo " +i);
|
||||
while(consecutivo1==false && j<dimensione){
|
||||
if (p_array[j] == p_array[i]+1){
|
||||
consecutivo1 = true;
|
||||
}
|
||||
Console.WriteLine("j1: " + j);
|
||||
j++;
|
||||
}
|
||||
j = 0;
|
||||
Console.WriteLine("i1: " + i);
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
j = 0;
|
||||
if(consecutivo1 == true){
|
||||
while(consecutivo2==false && i<dimensione){
|
||||
Console.WriteLine("Ciclo consecutivo 2 " +i);
|
||||
while(consecutivo2==false && j<dimensione){
|
||||
if (p_array[j] == p_array[i]+2){
|
||||
consecutivo2 = true;
|
||||
}
|
||||
Console.WriteLine("j2: " + j);
|
||||
j++;
|
||||
}
|
||||
j = 0;
|
||||
@ -193,4 +192,21 @@ class Program
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("array_funzioni_4")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[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.AssemblyTitleAttribute("array_funzioni_4")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
f8370efddee368823d742b2ce2af326cf9b4cbae328191ebab7352ed114ee1ba
|
||||
ca299e75237115b1e692d48d36398c1c127ee21df577772c1d66b6dd45a45494
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user