Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- struct Team
- {
- public string name;
- public int mark;
- public int razn;
- public Team(string n)
- {
- name = n;
- mark = 0;
- razn = 0;
- }
- }
- class Program
- {
- static void Game(ref Team t1, int sc1, ref Team t2, int sc2)
- {
- if (sc1 > sc2)
- {
- t1.mark += 3;
- t1.razn += sc1 - sc2;
- t2.razn += sc2 - sc1;
- }
- else if (sc1 == sc2)
- {
- t1.mark += 1;
- t2.mark += 1;
- }
- else
- {
- t2.mark += 3;
- t2.razn += sc2 - sc1;
- t1.razn += sc1 - sc2;
- }
- }
- static void Main(string[] args)
- {
- string[] names = new string[] { "Hound", "Kitty", "Sheep", "Horse" };
- Team[] tms = new Team[4];
- for (int i = 0; i < 4; i++)
- {
- tms[i].mark = 0;
- tms[i] = new Team(names[i]);
- }
- int[,] scores = new int[6, 2] {
- { 7, 3 },
- { 3, 1 },
- { 1, 4 },
- { 3, 3 },
- { 2, 1 },
- { 4, 0 }
- };
- int n = 0;
- for (int i = 0; i < 3; i++)
- {
- for (int j = i + 1; j < 4; j++)
- {
- Game(ref tms[i], scores[n, 0], ref tms[j], scores[n, 1]);
- n++;
- }
- }
- Team temp;
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- if (tms[j].mark < tms[j+1].mark)
- {
- temp = tms[j];
- tms[j] = tms[j + 1];
- tms[j + 1] = temp;
- }
- else if ((tms[j].mark == tms[j + 1].mark) && (tms[j].razn < tms[j+1].razn))
- {
- temp = tms[j];
- tms[j] = tms[j + 1];
- tms[j + 1] = temp;
- }
- }
- }
- foreach (Team x in tms)
- {
- Console.WriteLine("{0}\t {1}, {2}", x.name, x.mark, x.razn);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement