Advertisement
VladoG

PB-BG-Oct2018-ExamPrep-04.GroupStage

Nov 24th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04.GroupStage
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string teamName = Console.ReadLine();
  10.             int matchesNum = int.Parse(Console.ReadLine());
  11.             int goalsDiff = 0;
  12.             int score = 0;
  13.             int totalScoredGoals = 0;
  14.             int totalReceivedGoals = 0;
  15.  
  16.             for (int matches = 1; matches <= matchesNum; matches++)
  17.             {
  18.                 int scoredGoals = int.Parse(Console.ReadLine());
  19.                 int receivedGoals = int.Parse(Console.ReadLine());
  20.                 totalScoredGoals += scoredGoals;
  21.                 totalReceivedGoals += receivedGoals;
  22.                 if (scoredGoals > receivedGoals)
  23.                 {
  24.                     score += 3;
  25.                 }
  26.                 else
  27.                 {
  28.                     if (scoredGoals == receivedGoals)
  29.                     {
  30.                         score++;
  31.                     }
  32.                 }
  33.             }
  34.  
  35.             goalsDiff = totalScoredGoals - totalReceivedGoals;
  36.  
  37.             if (totalScoredGoals >= totalReceivedGoals)
  38.             {
  39.                 Console.WriteLine($"{teamName} has finished the group phase with {score} points.");
  40.                 Console.WriteLine($"Goal difference: {goalsDiff}.");
  41.             }
  42.             else
  43.             {
  44.                 Console.WriteLine($"{teamName} has been eliminated from the group phase.");
  45.                 Console.WriteLine($"Goal difference: {goalsDiff}.");
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement