Advertisement
silvana1303

easter competition

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