Advertisement
Guest User

easter Kozunak

a guest
Apr 21st, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 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 Easter_Competition
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberKozunaks = int.Parse(Console.ReadLine());
  14.             int max = int.MinValue;
  15.             string winner = string.Empty;
  16.             int lastSum = 0;
  17.  
  18.             for (int i = 0; i < numberKozunaks; i++)
  19.             {
  20.                 string chefName = Console.ReadLine();
  21.                 int sumEvaluation = 0;
  22.  
  23.                 while (true)
  24.                 {
  25.                     string command = Console.ReadLine();
  26.  
  27.                     if (command == "Stop")
  28.                     {
  29.                         break;
  30.                     }
  31.  
  32.                     int evaluation = int.Parse(command);
  33.                     sumEvaluation += evaluation;
  34.                    
  35.                     if (sumEvaluation > max)
  36.                     {
  37.                         max = sumEvaluation;
  38.                         winner = chefName;
  39.                     }
  40.                 }
  41.                 if (i == 0)
  42.                 {
  43.                     Console.WriteLine($"{chefName} has {sumEvaluation} points.");
  44.                     Console.WriteLine($"{chefName} is the new number 1!");
  45.                 }
  46.                 else if (sumEvaluation > lastSum)
  47.                 {
  48.                     Console.WriteLine($"{chefName} has {sumEvaluation} points.");
  49.                     Console.WriteLine($"{chefName} is the new number 1!");
  50.                 }
  51.                 else
  52.                 {
  53.                     Console.WriteLine($"{chefName} has {sumEvaluation} points.");
  54.                 }
  55.                 lastSum = sumEvaluation;
  56.             }
  57.             Console.WriteLine($"{winner} won competition with {max} points!");
  58.  
  59.  
  60.  
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement