MiroslavKisov

TriFunction

Feb 7th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace TriFunction
  5. {
  6.     public class StartUp
  7.     {
  8.         public static void Main()
  9.         {
  10.             int nameNumber = int.Parse(Console.ReadLine());
  11.             var names = Console.ReadLine()
  12.                 .Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)
  13.                 .ToArray();
  14.             for (int i = 0; i < names.Length; i++)
  15.             {
  16.                 int nameSum = 0;
  17.                 var currentName = names[i].ToCharArray();
  18.                 for (int j = 0; j < currentName.Length; j++)
  19.                 {
  20.                     nameSum += currentName[j];
  21.                     if (nameSum >= nameNumber)
  22.                     {
  23.                         Console.WriteLine(names[i]);
  24.                         Environment.Exit(0);
  25.                     }
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment