Advertisement
bpavlov123bp

GameOfNames

Jun 7th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. namespace GameOfNames
  4. {
  5. class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. int countOfPlayers = int.Parse(Console.ReadLine());
  10. int[] total = new int[countOfPlayers];
  11. int[] sum = new int[countOfPlayers];
  12. string[] nameOfPlayers = new string[countOfPlayers];
  13. int[] score = new int[countOfPlayers];
  14. int max = 0;
  15. int possition = 0;
  16. for(var i = 0; i < countOfPlayers; i++)
  17. {
  18. nameOfPlayers[i] = Console.ReadLine();
  19. score[i] = int.Parse(Console.ReadLine());
  20. foreach(var items in nameOfPlayers[i])
  21. {
  22. if((int)items % 2 == 0)
  23. {
  24. sum[i] += (int)items;
  25. }
  26. if((int)items % 2 != 0)
  27. {
  28. sum[i] -= (int)items;
  29. }
  30. }
  31. total[i] = sum[i] + score[i];
  32. max = total.Max();
  33. possition = Array.IndexOf(total, max);
  34. }
  35. Console.WriteLine("The winner is {0} - {1} points", nameOfPlayers[possition], max);
  36. Console.Write("Press any key to continue . . . ");
  37. Console.ReadKey(true);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement