Advertisement
TizzyT

BinomialEqualitiesGenerator -TizzyT

Sep 13th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BinomialEqualitiesGenerator
  4. {
  5.     class Program
  6.     {
  7.         private static Random RND = new Random();
  8.  
  9.         static void Main(string[] args)
  10.         {
  11.             while (true)
  12.             {
  13.                 int Difficulty;
  14.  
  15.                 do
  16.                 {
  17.                     Console.WriteLine("Choose a difficulty between 10 and " + ushort.MaxValue + " (inclusive)");
  18.                 } while (!(int.TryParse(Console.ReadLine(), out Difficulty) && Difficulty >= 10 && Difficulty <= ushort.MaxValue));
  19.  
  20.                 int X = RND.Next(1, Difficulty);
  21.                 int Y = RND.Next(1, Difficulty);
  22.  
  23.                 int LeftX = RND.Next(1, Difficulty);
  24.                 int LeftY = RND.Next(1, Difficulty);
  25.  
  26.                 int RightX = RND.Next(1, Difficulty);
  27.                 int RightY = RND.Next(1, Difficulty);
  28.  
  29.                 int LeftConst = RND.Next(((X + Y) / 2) * -1, (X + Y) / 2);
  30.  
  31.                 int LeftValue = (LeftX * X) + (LeftY * Y) + LeftConst;
  32.                 int RightValue = (RightX * X) + (RightY * Y);
  33.  
  34.                 int RightConst = LeftValue - RightValue;
  35.  
  36.                 Console.WriteLine(LeftX + "x+" + LeftY + "y" + (LeftConst > 0 ? "+" : "") + LeftConst + "=" + RightX + "x+" + RightY + "y" + (RightConst > 0 ? "+" : "") + RightConst);
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement