Advertisement
Spocoman

Basketball Tournament

Nov 26th, 2021 (edited)
82
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 BasketballTournament
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string tournament;
  10.             int win = 0, lost = 0;
  11.  
  12.             while ((tournament = Console.ReadLine()) != "End of tournaments")
  13.             {
  14.                 int games = int.Parse(Console.ReadLine());
  15.                 for (int game = 1; game <= games; game++)
  16.                 {
  17.                     int team1 = int.Parse(Console.ReadLine());
  18.                     int team2 = int.Parse(Console.ReadLine());
  19.  
  20.                     if (team1 > team2)
  21.                     {
  22.                         Console.WriteLine($"Game {game} of tournament {tournament}: win with {team1 - team2} points.");
  23.                         win++;
  24.                     }
  25.                     else
  26.                     {
  27.                         Console.WriteLine($"Game {game} of tournament {tournament}: lost with {team2 - team1} points.");
  28.                         lost++;
  29.                     }
  30.                 }
  31.             }
  32.  
  33.             Console.WriteLine($"{(double)win / (win + lost) * 100:F2}% matches win");
  34.             Console.WriteLine($"{(double)lost / (win + lost) * 100:F2}% matches lost");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement