marangoni

Великденски конкурс

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