knikolov98

Untitled

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