Commenti + opzione 3 + reset delle variabili nelle opzioni

This commit is contained in:
La Programmatrice Verde 2025-01-10 09:43:13 +01:00
parent 018f63991b
commit fae57d0cae
9 changed files with 28 additions and 7 deletions

View File

@ -5,9 +5,12 @@ class Program
static void Main(string[] args)
{
//dichiarazione e inizializzazione variabili
int scelta, i, numero, somma;
int scelta, i, numero, somma, tmp;
somma = 0;
bool positiviPari = true;
tmp = 0;
bool positiviPari, positivoNegativo;
positiviPari = true;
positivoNegativo = false;
//menu
do {
Console.WriteLine("Scegliere un'opzione:");
@ -23,6 +26,7 @@ class Program
case 0:
break;
case 1:
positiviPari = true;
do{
Console.Write("Numeri da inserire: ");
i = Convert.ToInt32(Console.ReadLine());
@ -34,7 +38,7 @@ class Program
for (; i > 0; i--){
Console.Write("Inserire un numero: ");
numero = Convert.ToInt32(Console.ReadLine());
if(numero < 0 || numero % 2 != 0){
if(numero < 0 || numero % 2 != 0){ //se non è positivo e pari
positiviPari = false;
}
}
@ -46,10 +50,11 @@ class Program
}
break;
case 2:
somma = 0;
do{
Console.Write("Inserire un numero: ");
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;
}
}
@ -57,6 +62,22 @@ class Program
Console.WriteLine("Somma: " + somma);
break;
case 3:
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:
break;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ripasso1")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[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.AssemblyTitleAttribute("ripasso1")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
f2c5cde86cd7c9aecef2ceb3af53f8d967d88c13fffb33996563a5258c59d278
042eecfbc24d3d06289088724a32fc5b4299d5aefd8aabe9fff63f62e1ef4676

Binary file not shown.

Binary file not shown.