Advertisement
simonakancheva

NameWars

Apr 20th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 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 _07.Name_Wars
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int current = 0;
  15.             int max = 0;
  16.             string namemax = "";
  17.             int max1 = int.MinValue;
  18.             while(true)
  19.             {
  20.  
  21.                 string name = Console.ReadLine();
  22.  
  23.                 if (name == "STOP")
  24.                     break;
  25.  
  26.                
  27.                 for (int i = 0; i < name.Length; i++)
  28.                     current = current + name[i];
  29.  
  30.                 if (current > max1 && current>max)
  31.                 {
  32.                     max = current;
  33.                     namemax = name;
  34.                     current = 0;
  35.                 }
  36.                 current = 0;
  37.  
  38.             }
  39.             Console.WriteLine($"Winner is {namemax} - {max}!");
  40.  
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement