private void button1_Click(object sender, EventArgs e)
{
double n = Convert.ToDouble(textBox3.Text);
double m = Convert.ToDouble(textBox2.Text);
double q = Convert.ToDouble(textBox1.Text);
richTextBox1.Text = "";
double[] a = new double[2 * (int)q];
Random r = new Random();
for (int i = 0; i < 2 * q; i++)
{
double temp = r.Next((int)m, (int)n);
a[i] = temp;
}
for (int i = 0; i < q; i++)
{
string c = "+";
double b = a[i] + a[i + (int)q];
if (b <= (int)n / 2)
c = "*";
if (b > (int)n / 2 && b <= (int)n)
c = "+";
if (b > (int)n && b <= (int)n * 1.5)
c = "/";
if (b > (int)n * 1.5 && b <= (int)n * 2 && a[i] > a[i + (int)q])
c = "-";
richTextBox1.AppendText(a[i].ToString() + (c) + a[i + (int)q].ToString() + ("=") + System.Environment.NewLine);
}
}
}
}
原文地址:https://www.cnblogs.com/lwan/p/9750806.html