Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06._Easter_Competition
  4. {
  5.     class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.  
  10.             int n = int.Parse(Console.ReadLine());
  11.             string chef = "";
  12.             int maxscore = 0;
  13.  
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 string name = Console.ReadLine();
  17.                 string score = Console.ReadLine();
  18.                 int sum = 0;
  19.  
  20.                 while (score != "Stop")
  21.                 {
  22.                     sum += int.Parse(score);
  23.                     score = Console.ReadLine();
  24.                 }
  25.  
  26.                 Console.WriteLine(name + " has " + sum + " points.");
  27.  
  28.                 if (sum > maxscore)
  29.                 {
  30.                     maxscore = sum;
  31.                     chef = name;
  32.                     Console.WriteLine(name + " is the new number 1!");
  33.                 }
  34.             }
  35.  
  36.             Console.WriteLine(chef + " won competition with " + maxscore + " points!");
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement