veselka_a

6.EasternCompetition

Feb 24th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 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 _6.EasternCompetition
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int EasterBreads = int.Parse(Console.ReadLine());
  14.            
  15.             int tempPoints = 0;
  16.             int currentPoints = 0;
  17.             int maxPoints =currentPoints;
  18.             string bestChefName = string.Empty;
  19.          
  20.  
  21.           string chefName = string.Empty;
  22.  
  23.             for (int i = 1; i <= EasterBreads; i++)
  24.             {
  25.  
  26.                 chefName = Console.ReadLine();
  27.                 string input = Console.ReadLine();
  28.                 while (input!="Stop")
  29.                 {
  30.                     currentPoints = int.Parse(input);
  31.                     tempPoints += currentPoints;
  32.                     input = Console.ReadLine();
  33.  
  34.                 }
  35.                 Console.WriteLine($"{chefName} has {tempPoints} points.");
  36.                
  37.  
  38.                 if (maxPoints<tempPoints)
  39.                 {
  40.                     Console.WriteLine($"{chefName} is the new number 1!");
  41.                     maxPoints = tempPoints;
  42.                     bestChefName = chefName;
  43.                 }
  44.                 tempPoints = 0;
  45.  
  46.             }
  47.             Console.WriteLine($"{bestChefName} won competition with {maxPoints} points!");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment