using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace 出题 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int a, b, c, d; Random shu = new Random(); Random fuhao = new Random(); int shuzi1= shu.Next(10, 100); textBox1.Text=shuzi1.ToString(); int shuzi2 = shu.Next(10, 100);//取0-100的随机数 textBox3.Text = shuzi2.ToString(); a=shuzi1 +shuzi2 ; b=shuzi1 -shuzi2 ; c=shuzi1 *shuzi2 ; d = shuzi1 / shuzi2; int fuhao1=fuhao.Next(1, 5);//取1-4的随机数用来对应运算符号 //用于接受运算符号 switch (fuhao1)//判断运算符号 { case 1: textBox2.Text = "+"; textBox4.Text =Convert.ToString(a); break; case 2: textBox2.Text = "-"; textBox4.Text=Convert.ToString(b); break; case 3: textBox2.Text = "*"; textBox4.Text=Convert.ToString(c); break; case 4: textBox2.Text = "/"; textBox4.Text=Convert.ToString(d); break; } //第一个运算符号 } private void button3_Click(object sender, EventArgs e) { Application.Exit(); } private void button2_Click(object sender, EventArgs e) { textBox6.Text = textBox4.Text; } private void textBox5_TextChanged(object sender, EventArgs e) { textBox5.Focus(); } private void textBox7_TextChanged(object sender, EventArgs e) { } } }
原文:https://www.cnblogs.com/moxizi/p/9769523.html