如果,此时的你,依旧没有开学;
恰巧可能还要辅导作业,
然后都是些小学生,
那么可以的话,你就试着做一个小程序。
以下用c#做的一个窗体程序,内容简单,功能凑合
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 WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int a, b;
string op;
int result;
Random rnd = new Random();
private void Form1_Load(object sender, EventArgs e)
{
}
private void BtnNew_Click(object sender, EventArgs e)
{
a = rnd.Next(9) + 1;
b = rnd.Next(9) + 1;
int c = rnd.Next(4);
switch (c)
{
case 0: op = "+"; result = a + b; break;
case 1: op = "-"; result = a - b; break;
case 2: op = "*"; result = a * b; break;
case 3: op = "/"; result = a / b; break;
}
lblA.Text = a.ToString();
lblB.Text = b.ToString();
lblOp.Text = op;
txtAnswer.Text = "";
}
private void BtnJudge_Click(object sender, EventArgs e)
{
string str = txtAnswer.Text;
double d = double.Parse(str);
string disp = "" + a + op + b + "=" + str + " ";
if (d == result) // if( Math.Abs(d-result)< 1e-3 )
disp += "√ 答案正确 ";
else
disp += "╳ 答案错误 ";
lstDisp.Items.Add(disp);
}
}
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/114791.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...