Advertisement
braveheart1989

Game of Names_Условие

Apr 24th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 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 _02.Exam2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int numberOfPlayers = int.Parse(Console.ReadLine());
  14. string name = "";
  15. int initialscore = 0;
  16. int score = 0;
  17. int maxScore = int.MinValue;
  18. List<int> scoreContent = new List<int>();
  19. List<string> nameContent = new List<string>();
  20. string winner = "";
  21. for (int i = 0; i < numberOfPlayers; i++)
  22. {
  23.  
  24. name = Console.ReadLine();
  25. initialscore = int.Parse(Console.ReadLine());
  26. foreach (var ch in name)
  27. {
  28. if (ch % 2 == 0)
  29. {
  30. score += ch;
  31. }
  32. else
  33. {
  34. score -= ch;
  35. }
  36. }
  37.  
  38. if (score + initialscore > maxScore)
  39. {
  40. maxScore = score+initialscore;
  41. winner = name;
  42. }
  43. scoreContent.Add(initialscore + score);
  44. score = 0;
  45. }
  46. Console.WriteLine("The winner is {0} - {1} points",winner,maxScore);
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement