Skip to content

Instantly share code, notes, and snippets.

@nasko90
Created October 16, 2016 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasko90/9b585c5d4b34a90953338e7966316ef3 to your computer and use it in GitHub Desktop.
Save nasko90/9b585c5d4b34a90953338e7966316ef3 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
namespace HelloWorld
{
class vendingMaschine
{
static void Main()
{
int n = int.Parse(Console.ReadLine());
int[] rounds = new int[n];
int v = 0;
int m = 0;
if (1 <= n && n <= 100)
{
for (int i = 0; i < rounds.Length; i++)
{
if (rounds[i] <= 999999999)
{
rounds[i] = int.Parse(Console.ReadLine());
string beers = rounds[i].ToString();
byte[] beer = beers.ToCharArray().Select(c => byte.Parse(c.ToString())).ToArray();
if (beer.Length % 2 == 0)
{
for (int index = 0; index < beer.Length; index++)
{
if (index < beer.Length / 2)
{
m += beer[index];
}
else
{
v += beer[index];
}
}
}
if (beer.Length % 2 != 0)
{
for (int index = 0; index < beer.Length; index++)
{
if (index <= beer.Length / 2)
{
m += beer[index];
}
if (index >= beer.Length / 2)
{
v += beer[index];
}
}
}
}
}
if (m > v)
{
Console.WriteLine("M" +" "+ (m - v));
}
if (m < v)
{
Console.WriteLine("V" +" "+ (v - m));
}
if (m == v)
{
Console.WriteLine("No" + " "+ (m + v));
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment