Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace BasketballTournament
- {
- class Program
- {
- static void Main(string[] args)
- {
- string tournamentName = string.Empty;
- int matchesWin = 0;
- int matchesLost = 0;
- int matchNumber = 0;
- int totalMatchNumber = 0;
- double percentageWin = 0;
- double percentageLost = 0;
- while (tournamentName != "End of tournaments")
- {
- tournamentName = Console.ReadLine();
- if (tournamentName == "End of tournaments")
- {
- break;
- }
- matchNumber = int.Parse(Console.ReadLine());
- totalMatchNumber += matchNumber;
- for (int i = 1; i <= matchNumber; i++)
- {
- int ownPoints = int.Parse(Console.ReadLine());
- int oponentPoints = int.Parse(Console.ReadLine());
- if (ownPoints > oponentPoints)
- {
- matchesWin++;
- Console.WriteLine($"Game {i} of tournament {tournamentName}: win with {ownPoints - oponentPoints} points.");
- }
- else if (ownPoints < oponentPoints)
- {
- matchesLost++;
- Console.WriteLine($"Game {i} of tournament {tournamentName}: lost with {oponentPoints - ownPoints} points.");
- }
- }
- percentageWin = matchesWin * 100 * 1.0 / totalMatchNumber;
- percentageLost = matchesLost * 100 * 1.0 / totalMatchNumber;
- }
- Console.WriteLine($"{percentageWin:f2}% matches win");
- Console.WriteLine($"{percentageLost:f2}% matches lost");
- }
- }
- }
Add Comment
Please, Sign In to add comment