Advertisement
serhiy1994

football score generator

Jul 29th, 2022
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. Random r = new Random();
  2.         private void button11_Click(object sender, EventArgs e)
  3.         {
  4.             int agg;
  5.             int h1, h2, a1, a2;
  6.             textBox1.Clear();
  7.             for (int i = 1; i <= 20; i++) //48-40-20-20
  8.             {
  9.                 do
  10.                 {
  11.                     agg = r.Next(0, 3);
  12.                     h1 = agg == 0 ? r.Next(0, 5) : r.Next(0, 9);
  13.                     h2 = agg == 0 ? r.Next(0, 5) : r.Next(0, 9);
  14.                     a1 = agg == 0 ? h1 : r.Next(0, 9);
  15.                     a2 = agg == 0 ? h2 : r.Next(0, 9);
  16.                 } while (agg == 0 ? (h1 + a2) == (h2 + a1) : (agg == 1 ? (h1 + a2) >= (h2 + a1) : (h1 + a2) <= (h2 + a1)));
  17.                 textBox1.Text += $"{i}. " + (agg == 1 && (h1 + a2) == (h2 + a1) ? $"{h1}:{a1}, {h2}:{a1}H" : (agg == 2 && (h1 + a2) == (h2 + a1) ? $"{h1}:{a1}, {h2}:{a1}A" : $"{h1}:{a1}, {h2}:{a1}")) + Environment.NewLine;
  18.             }
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement