aggressiveviking

Untitled

Feb 18th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.EasterCompetition
  4. {
  5.     class EasterCompetition
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int count = int.Parse(Console.ReadLine());
  10.             string bestBakerName = "";
  11.             int bestBakerPoints = -1;
  12.  
  13.             for (int i = 0; i < count; i++)
  14.             {
  15.                 string bakerName = Console.ReadLine();
  16.                 int points = 0;
  17.                 string command = Console.ReadLine();
  18.  
  19.                 while (command != "Stop")
  20.                 {
  21.                     points += int.Parse(command);
  22.                     command = Console.ReadLine();
  23.                 }
  24.  
  25.                 Console.WriteLine($"{bakerName} has {points} points.");
  26.                
  27.                 if (points > bestBakerPoints)
  28.                 {
  29.                     bestBakerName = bakerName;
  30.                     bestBakerPoints = points;
  31.                     Console.WriteLine($"{bakerName} is the new number 1!");
  32.                 }
  33.             }
  34.  
  35.             Console.WriteLine($"{bestBakerName} won competition with {bestBakerPoints} points!");
  36.  
  37.         }
  38.  
  39.        
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment