Guest User

GameOfNames

a guest
Apr 28th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Names
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int playersCount = int.Parse(Console.ReadLine());
  14.             string winner = string.Empty;
  15.             int maxScore = int.MinValue;
  16.  
  17.             for (int i = 0; i < playersCount; i++)
  18.             {
  19.                
  20.                 string playerName = Console.ReadLine();
  21.                 int initialScore = int.Parse(Console.ReadLine());
  22.                
  23.                 for (int j = 0; j < playerName.Length; j++)
  24.                 {
  25.                     if (playerName[j] % 2 == 0)
  26.                     {
  27.                         initialScore += playerName[j];
  28.                     }
  29.                     else
  30.                     {
  31.                         initialScore -= playerName[j];
  32.                     }
  33.                 }
  34.  
  35.                 if (initialScore > maxScore)
  36.                 {
  37.                     maxScore = initialScore;
  38.                     winner = playerName;
  39.                 }
  40.             }
  41.  
  42.             Console.WriteLine("The winner is {0} - {1} points", winner, maxScore);
  43.         }
  44.     }
  45. }
Add Comment
Please, Sign In to add comment