Opzione 2 + semplifica funzione CreaArrayCasuale per i test
This commit is contained in:
parent
5f2e5f314c
commit
fee784ed53
25
Program.cs
25
Program.cs
@ -35,6 +35,8 @@ class Program
|
||||
break;
|
||||
case 2:
|
||||
Console.Clear();
|
||||
array = CreaArrayCasuale();
|
||||
Console.WriteLine(StampaPariDispari(array));
|
||||
Pausa();
|
||||
break;
|
||||
case 3:
|
||||
@ -85,7 +87,7 @@ class Program
|
||||
int[] ritorno=new int[dimensione];
|
||||
|
||||
for(int i=0; i<dimensione; i++){
|
||||
ritorno[i] = caso.Next(Int32.MinValue, Int32.MaxValue);
|
||||
ritorno[i] = caso.Next(1, 10);//sostituire 1, 10 con Int32.MinValue, Int32.MaxValue quando è pronto tutto
|
||||
}
|
||||
return ritorno;
|
||||
}
|
||||
@ -110,4 +112,25 @@ class Program
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static string StampaPariDispari(int[] p_array){
|
||||
int sommaPari=0, sommaDispari=0, i=0;
|
||||
string ritorno;
|
||||
while(i<dimensione){
|
||||
sommaPari=sommaPari+p_array[i];
|
||||
i = i + 2;
|
||||
}
|
||||
i = 1;
|
||||
while(i<dimensione){
|
||||
sommaDispari=sommaDispari+p_array[i];
|
||||
i = i + 2;
|
||||
}
|
||||
if (sommaPari == sommaDispari){
|
||||
ritorno="Pari e dispari uguali";
|
||||
}
|
||||
else{
|
||||
ritorno = "Pari e dispari diversi";
|
||||
}
|
||||
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+dbc865b3c78a32f557c013629494305cc9facffb")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5f2e5f314cc25d4add28917ab10f2ac7b722e0a5")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("array_funzioni_4")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("array_funzioni_4")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
b2b910420808c412e0672626769c980cd8ccb42c4a7b33086fa2128f8e85f3d4
|
||||
e65c3edfadf2260ad347a303cdc21e3f11b0f69c4c8c8208c11f05a47bd78320
|
||||
|
||||
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