/* Write a random math problem, you calculate the answer to the program */
Using System;
Namespace Test {
public class test{
/* Judgment is correct */
public static bool Fun1 (int[] randoms,int readline_info)
{
int right_result = Randoms[0] + randoms[1];
if (Readline_info = = Right_result)
return true;
Else
{
return false;
}
}
/* generates two random integers */
public static int[] Fun2 () {
int[] randoms = new int[2];
int x, y;
Random ran = new random ();
x = ran. Next (1, 100);
y = ran. Next (1, 100);
Randoms[0] = x;
Randoms[1] = y;
Console.WriteLine (x + "+" + y + "=?");
return randoms;
}
public static void Main ()
{
BOOL result = FALSE;
while (result) {
int readline_info;
int[] randoms = fun2 ();
Console.WriteLine ("+");
string to int, using INT. Parse (str), efficient and non-throwing exception
readline_info = Int. Parse (Console.ReadLine ());
Fun1 (randoms, readline_info);
if (result = = True)
Break
}
}
}
}
Demonstrate C # BASIC program structure with a small demo--arithmetic problem in the console