Advertisement
GeorgiGanev

Game Wars

Nov 16th, 2019
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Name_Wars
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. {
  10. string name = Console.ReadLine();
  11.  
  12. string maxName = string.Empty;
  13. int maxSum = 0;
  14.  
  15. while (name != "STOP")
  16. {
  17. int sum = 0;
  18. for (int i = 0; i < name.Length; i++)
  19. {
  20. char letter = name[i];
  21. sum += letter;
  22. }
  23. if (sum > maxSum)
  24. {
  25. maxSum = sum;
  26. maxName = name;
  27. }
  28. name = Console.ReadLine();
  29. }
  30. Console.WriteLine($"Winner is {maxName} - {maxSum}!");
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement