Advertisement
Valantina

BasketballTournament/EX

Jun 13th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BasketballTournament
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int wonCount = 0, lostCount = 0, total = 0; ;
  10.             string name = string.Empty;
  11.             while (true)
  12.             {
  13.                 name = Console.ReadLine();
  14.                 if (name == "End of tournaments")
  15.                 {
  16.                     break;
  17.                 }
  18.                 int n = int.Parse(Console.ReadLine());
  19.                 total += n;
  20.                 for (int i = 1; i <= n; i++)
  21.                 {
  22.                     int scoredPts = int.Parse(Console.ReadLine());
  23.                     int recievedPts = int.Parse(Console.ReadLine());
  24.                     bool win = scoredPts > recievedPts;
  25.                     if (win)
  26.                     {
  27.                         Console.WriteLine($"Game {i} of tournament {name}: win with {scoredPts - recievedPts} points.");
  28.                         wonCount++;
  29.                     }
  30.                     else
  31.                     {
  32.                         Console.WriteLine($"Game {i} of tournament {name}: lost with {Math.Abs(scoredPts - recievedPts)} points.");
  33.                         lostCount++;
  34.                     }
  35.  
  36.                 }
  37.             }
  38.             double winPercent = (double)wonCount / total * 100;
  39.             Console.WriteLine($"{winPercent:f2}% matches win");
  40.             Console.WriteLine($"{100 - winPercent:f2}% matches lost");
  41.         }
  42.     }
  43.    
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement