Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 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 ConsoleApplication1
  8. {
  9.     struct Team
  10.     {
  11.         public string name;
  12.         public int mark;
  13.         public int razn;
  14.         public Team(string n)
  15.         {
  16.             name = n;
  17.             mark = 0;
  18.             razn = 0;
  19.         }
  20.     }
  21.     class Program
  22.     {
  23.         static void Game(ref Team t1, int sc1, ref Team t2, int sc2)
  24.         {
  25.             if (sc1 > sc2)
  26.             {
  27.                 t1.mark += 3;
  28.                 t1.razn += sc1 - sc2;
  29.                 t2.razn += sc2 - sc1;
  30.             }
  31.             else if (sc1 == sc2)
  32.             {
  33.                 t1.mark += 1;
  34.                 t2.mark += 1;
  35.             }
  36.             else
  37.             {
  38.                 t2.mark += 3;
  39.                 t2.razn += sc2 - sc1;
  40.                 t1.razn += sc1 - sc2;
  41.             }
  42.         }
  43.         static void Main(string[] args)
  44.         {
  45.             string[] names = new string[] { "Hound", "Kitty", "Sheep", "Horse" };
  46.             Team[] tms = new Team[4];
  47.             for (int i = 0; i < 4; i++)
  48.             {
  49.                 tms[i].mark = 0;
  50.                 tms[i] = new Team(names[i]);
  51.             }
  52.             int[,] scores = new int[6, 2] {
  53. { 7, 3 },
  54. { 3, 1 },
  55. { 1, 4 },
  56. { 3, 3 },
  57. { 2, 1 },
  58. { 4, 0 }
  59. };
  60.             int n = 0;
  61.             for (int i = 0; i < 3; i++)
  62.             {
  63.                 for (int j = i + 1; j < 4; j++)
  64.                 {
  65.                     Game(ref tms[i], scores[n, 0], ref tms[j], scores[n, 1]);
  66.                     n++;
  67.                 }
  68.             }
  69.             Team temp;
  70.             for (int i = 0; i < 4; i++)
  71.             {
  72.                 for (int j = 0; j < 3; j++)
  73.                 {
  74.                     if (tms[j].mark < tms[j+1].mark)
  75.                     {
  76.                         temp = tms[j];
  77.                         tms[j] = tms[j + 1];
  78.                         tms[j + 1] = temp;
  79.                     }
  80.                     else if ((tms[j].mark == tms[j + 1].mark) && (tms[j].razn < tms[j+1].razn))
  81.                     {
  82.                         temp = tms[j];
  83.                         tms[j] = tms[j + 1];
  84.                         tms[j + 1] = temp;
  85.                     }
  86.                 }
  87.             }
  88.             foreach (Team x in tms)
  89.             {
  90.                 Console.WriteLine("{0}\t {1}, {2}", x.name, x.mark, x.razn);
  91.             }
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement