Skip to content

Instantly share code, notes, and snippets.

@jean-lourenco
Created October 15, 2017 23:59
Show Gist options
  • Save jean-lourenco/a1dbd94a9687b25b64735cd42d920ca6 to your computer and use it in GitHub Desktop.
Save jean-lourenco/a1dbd94a9687b25b64735cd42d920ca6 to your computer and use it in GitHub Desktop.
using System;
namespace coisas
{
public class Program
{
public static void Main(string[] args)
{
var total = 0;
var impares = 0;
var pares = 0;
var maiores100 = 0;
while (true)
{
Console.WriteLine("Informe um número");
if (!Int32.TryParse(Console.ReadLine(), out var valor))
continue;
if (valor == 0)
break;
if (valor % 2 == 0)
pares++;
else
impares++;
if (valor > 100)
maiores100++;
total += valor;
}
Console.WriteLine($@"
Total de valores: {pares + impares}
Total de pares: {pares}
Total de ímpares: {impares}
Acima de 100: {maiores100}
Média dos valores: {total / Math.Max(pares + impares, 1)};
");
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment