C#编程问题。
利用计算机随机出一道100以内的加,减法,并根据用户的答案给出"Right"或"Wrong"的提示信息。...
利用计算机随机出一道100以内的加,减法,并根据用户的答案给出"Right"或"Wrong"的提示信息。
展开
1个回答
推荐于2016-11-08 · 知道合伙人软件行家
关注
展开全部
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string answer;
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = pp();
}
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text != answer)
{
MessageBox.Show("错了");
}
else
{
label1.Text = pp();
}
}
private string pp()
{
Random random = new Random();
int a = random.Next(1, 100);
int b = random.Next(1, 100 - a);
answer = (a + b).ToString();
return a + "+" + b + "=";
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string answer;
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = pp();
}
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text != answer)
{
MessageBox.Show("错了");
}
else
{
label1.Text = pp();
}
}
private string pp()
{
Random random = new Random();
int a = random.Next(1, 100);
int b = random.Next(1, 100 - a);
answer = (a + b).ToString();
return a + "+" + b + "=";
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询