aneliabogeva

Untitled

Mar 15th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _06.Coins
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string name = Console.ReadLine();
  14.             int playedGames = int.Parse(Console.ReadLine());
  15.  
  16.             int sendGoals = int.Parse(Console.ReadLine());
  17.             int receivedGoals = int.Parse(Console.ReadLine());
  18.  
  19.             int totalreceivedGoals = 0;
  20.             int totalsendGoals = 0;
  21.             int totalPoins = 0;
  22.             int totalGoalDiff = 0;
  23.  
  24.  
  25.             int points = 0;
  26.             int counter = 1;
  27.             int goalDiff = 0;
  28.  
  29.             while (counter <= playedGames)
  30.             {
  31.                 if (receivedGoals < sendGoals)
  32.                 {
  33.                     points = points + 3;
  34.                     goalDiff = sendGoals - receivedGoals;
  35.                 }
  36.                 else if (receivedGoals > sendGoals)
  37.                 {
  38.                     points = points + 0;
  39.                     goalDiff = receivedGoals - sendGoals;
  40.                 }
  41.                 else
  42.                 {
  43.                     points = points + 1;
  44.                     goalDiff = 0;
  45.                 }
  46.  
  47.                 totalreceivedGoals = totalreceivedGoals + receivedGoals;
  48.                 totalsendGoals = totalsendGoals + sendGoals;
  49.                 totalGoalDiff = totalGoalDiff + goalDiff;
  50.                 totalPoins = points;
  51.                 counter++;
  52.                 if (counter <= playedGames)
  53.                 {
  54.                     sendGoals = int.Parse(Console.ReadLine());
  55.                     receivedGoals = int.Parse(Console.ReadLine());
  56.                 }
  57.  
  58.             }
  59.  
  60.             if (totalsendGoals >= totalreceivedGoals)
  61.             {
  62.                 Console.WriteLine($"{name} has finished the group phase with {totalPoins} points.");
  63.                 Console.WriteLine($"Goal difference: {totalGoalDiff}");
  64.             }
  65.             else
  66.             {
  67.                 Console.WriteLine($"{name} has been eliminated from the group phase.");
  68.                 Console.WriteLine($"Goal difference: {totalsendGoals - totalreceivedGoals}");
  69.             }
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment