Commenti + opzione 3 + reset delle variabili nelle opzioni
This commit is contained in:
parent
018f63991b
commit
fae57d0cae
31
Program.cs
31
Program.cs
@ -5,9 +5,12 @@ class Program
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//dichiarazione e inizializzazione variabili
|
//dichiarazione e inizializzazione variabili
|
||||||
int scelta, i, numero, somma;
|
int scelta, i, numero, somma, tmp;
|
||||||
somma = 0;
|
somma = 0;
|
||||||
bool positiviPari = true;
|
tmp = 0;
|
||||||
|
bool positiviPari, positivoNegativo;
|
||||||
|
positiviPari = true;
|
||||||
|
positivoNegativo = false;
|
||||||
//menu
|
//menu
|
||||||
do {
|
do {
|
||||||
Console.WriteLine("Scegliere un'opzione:");
|
Console.WriteLine("Scegliere un'opzione:");
|
||||||
@ -23,6 +26,7 @@ class Program
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
positiviPari = true;
|
||||||
do{
|
do{
|
||||||
Console.Write("Numeri da inserire: ");
|
Console.Write("Numeri da inserire: ");
|
||||||
i = Convert.ToInt32(Console.ReadLine());
|
i = Convert.ToInt32(Console.ReadLine());
|
||||||
@ -34,7 +38,7 @@ class Program
|
|||||||
for (; i > 0; i--){
|
for (; i > 0; i--){
|
||||||
Console.Write("Inserire un numero: ");
|
Console.Write("Inserire un numero: ");
|
||||||
numero = Convert.ToInt32(Console.ReadLine());
|
numero = Convert.ToInt32(Console.ReadLine());
|
||||||
if(numero < 0 || numero % 2 != 0){
|
if(numero < 0 || numero % 2 != 0){ //se non è positivo e pari
|
||||||
positiviPari = false;
|
positiviPari = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,10 +50,11 @@ class Program
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
somma = 0;
|
||||||
do{
|
do{
|
||||||
Console.Write("Inserire un numero: ");
|
Console.Write("Inserire un numero: ");
|
||||||
numero = Convert.ToInt32(Console.ReadLine());
|
numero = Convert.ToInt32(Console.ReadLine());
|
||||||
if (!((numero < 0 && numero % 2 == 0) || (numero >= 0 && numero % 3 == 0))){
|
if (!((numero < 0 && numero % 2 == 0) || (numero >= 0 && numero % 3 == 0))){ //se non è ((minore di zero e divisibile per 2) o è ((maggiore o uguale a zero) e divisibile per 3))
|
||||||
somma = somma + numero;
|
somma = somma + numero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +62,23 @@ class Program
|
|||||||
Console.WriteLine("Somma: " + somma);
|
Console.WriteLine("Somma: " + somma);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
break;
|
positivoNegativo = false;
|
||||||
|
do{
|
||||||
|
Console.Write("Inserire un numero: ");
|
||||||
|
numero = Convert.ToInt32(Console.ReadLine());
|
||||||
|
if(numero > 0 && tmp < 0){
|
||||||
|
positivoNegativo = true;
|
||||||
|
}
|
||||||
|
tmp = numero;
|
||||||
|
}
|
||||||
|
while (numero != 0);
|
||||||
|
if(positivoNegativo){
|
||||||
|
Console.WriteLine("OK");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Console.WriteLine("NO");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
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("ripasso1")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("ripasso1")]
|
||||||
[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+e1c4d5e33e3928d02e8d2d8c5dad601ee6a069b7")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+018f63991bf194f27f28e5f478eb7c5a8784aa89")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("ripasso1")]
|
[assembly: System.Reflection.AssemblyProductAttribute("ripasso1")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("ripasso1")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("ripasso1")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
f2c5cde86cd7c9aecef2ceb3af53f8d967d88c13fffb33996563a5258c59d278
|
042eecfbc24d3d06289088724a32fc5b4299d5aefd8aabe9fff63f62e1ef4676
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user