Guest User

Untitled

a guest
Apr 24th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 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 _02GamesOfNames
  8. {
  9. class GamesOfNAMes
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int maxSum = int.MinValue;
  15. string newName = string.Empty;
  16. for (int i = 0; i < n; i++)
  17. {
  18. string name = Console.ReadLine();
  19. int score = int.Parse(Console.ReadLine());
  20. int sum = score;
  21. for (int j = 0; j < name.Length; j++)
  22. {
  23. if (name[j] % 2 == 0)
  24. {
  25. sum += name[j];
  26. }
  27. else
  28.  
  29. {
  30. sum -= name[j];
  31. }
  32. }
  33. if (sum > maxSum)
  34. {
  35. maxSum = sum;
  36. newName = name;
  37. }
  38. }
  39. Console.WriteLine("The winner is {0} - {1} points", newName,maxSum);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment