5. 印度小朋友的心算

namespace Q5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
            textBox2.Clear();
            textBox3.Clear();
            sol.Text = "";
            result.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var m = int.Parse(textBox1.Text);
            var n = int.Parse(textBox2.Text);
            var ans = int.Parse(textBox3.Text);

            var yes = m * n == ans;

            result.Text = yes ? "Very Good!" : "is wrong";
            if (!yes)
            {
                sol.Text = @$"(1) {m}+{n % 10}={(m + n % 10)}
(2) {(m + n % 10)}X{(m / 10) * 10}={(m + n % 10) * ((m / 10) * 10)}
(3) {m % 10}X{n % 10}={(m % 10) * (n % 10)}
(4) {(m + n % 10) * ((m / 10) * 10)}+{(m % 10) * (n % 10)}={m * n}";
            }
            else
            {
                sol.Text = "";
            }
        }
    }
}

Last updated