Created
October 16, 2016 13:38
-
-
Save nasko90/9b585c5d4b34a90953338e7966316ef3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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