Program Na Vypočítání Úkolu z Matematiky

(Program je v C# a webová verze v JavaScriptu)

(bráchovo stránka: https://web.akac.ml)


Zde si můžete můj nástroj vyzkoušet z prohlížeče. Do políčka níže zadejte 5 čísel oddělených mezerou, kde bude výsledek 10.

Kód:

    
Random r = new Random();
string[] problem = new string[5] { "1", "2", "3", "4", "6" };

double output = 0;

while (output != 10)
{
  string check = "";
  char[] chars = new char[4];

  for (int i = 0; i < chars.Length; i++)
  {
      int num = r.Next(0, 2);

      if (num == 0)
      {
chars[i] = '+';
      }
      else if (num == 1)
      {
chars[i] = '-';
      }
  }

  check = problem[0] + chars[0] + problem[1] + chars[1] + problem[2] + chars[2] + problem[3] + chars[3] + problem[4];
  Console.WriteLine(check);
  output = Evaluate(check);

  Console.WriteLine(output);
}