SHARE
TWEET

Untitled

a guest Mar 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace Task6
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double matchNumber = 0;
  10.             double matchesWon = 0;
  11.             double matchesLost = 0;
  12.             double totalMatches = 0;
  13.  
  14.             double percentWins = 0;
  15.             double percentLoss = 0;
  16.  
  17.             string opponentTeam = Console.ReadLine();
  18.  
  19.             while (opponentTeam != "End of tournaments")
  20.             {
  21.                 int numberOfMatches = int.Parse(Console.ReadLine());
  22.                 totalMatches += numberOfMatches;
  23.  
  24.                 for (int i = 0; i < numberOfMatches; i++)
  25.                 {
  26.                     int firstScore = int.Parse(Console.ReadLine());
  27.                     int secondScore = int.Parse(Console.ReadLine());
  28.                     int scoreDiff = Math.Abs(firstScore - secondScore);
  29.                     int difference = 0;
  30.  
  31.                     ++matchNumber;
  32.  
  33.  
  34.                     if (firstScore > secondScore)
  35.                     {
  36.                         difference = difference + scoreDiff;
  37.                         Console.WriteLine($"Game {matchNumber} of tournament {opponentTeam}: win with {difference} points.");
  38.                         matchesWon++;
  39.                     }
  40.                     else
  41.                     {
  42.                         difference = difference + scoreDiff;
  43.                         Console.WriteLine($"Game {matchNumber} of tournament {opponentTeam}: lost with {difference} points.");
  44.                         matchesLost++;
  45.                     }
  46.  
  47.  
  48.  
  49.                 }
  50.                 opponentTeam = Console.ReadLine();
  51.                 matchNumber = 0;
  52.  
  53.                 if (opponentTeam == "End of Tournaments")
  54.                 {
  55.  
  56.                     break;
  57.                 }
  58.  
  59.  
  60.  
  61.             }
  62.  
  63.             percentWins = ((matchesWon / totalMatches)) * 100;
  64.             percentLoss = ((matchesLost / totalMatches)) * 100;
  65.             Console.WriteLine($"{percentWins:F2}% matches win");
  66.             Console.WriteLine($"{percentLoss:F2}% matches lost");
  67.  
  68.         }
  69.     }
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top