Advertisement
Guest User

09. Name Wars

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