欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
一個用C#寫的小學數學出題聯系系統源代碼
[打印本頁]
作者:
liuboyang2020
時間:
2020-11-29 23:26
標題:
一個用C#寫的小學數學出題聯系系統源代碼
c#寫的小學數學二年級自動出題系統,實現自動隨機出題;四則運算。對于剛學C#的朋友掌握光標獲取、鎖定光標,TAB切換、回車鍵綁定、隨機數產生、列表框顯示運用等有幫助!
51hei.png
(6.98 KB, 下載次數: 102)
下載附件
2020-12-13 17:35 上傳
源程序如下:
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,aaa,bbb,bb;
string op;
string op1;
string op2;
int result;
int result1;
int result2;
Random rnd = new Random();
private void Form1_Load(object sender, EventArgs e)
{
}
private void Button1Click(object sender, EventArgs e)
{
a = rnd.Next(10) + 1;
b = rnd.Next(10) + 1;
if (a<=b)
a=a+b;
aaa = rnd.Next(10) + 1;
bbb = rnd.Next(10) + 1;
if (aaa<=bbb)
aaa=aaa+bbb;
bb = rnd.Next(8) + 1;
int c = rnd.Next(3);
int cc = rnd.Next(3);
int ccc = rnd.Next(2);
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;
}
switch (cc)
{
case 0: op1 = "+"; result1 = aaa + bbb ; break;//OP1表示當前運算符號和結果,運算結果result1等于加數+加數
case 1: op1 = "-"; result1 = aaa - bbb ; break;//OP1表示當前運算符號和結果,運算結果result1等于被減數-減數
case 2: op1 = "×"; result1 = aaa * bbb ; break;//OP1表示當前運算符號和結果,運算結果result1等于乘數*乘數
case 3: op1 = "÷"; result1 = aaa / bbb ; break;//OP1表示當前運算符號和結果,運算結果result1等于除數/除數
}
switch (ccc)
{
case 0: op2 = "+"; result2 = result1 + bb; break;
case 1: op2 = "×"; result2 = result1 * bb; break;
}
textBox2.Text = a.ToString();//算式1中的從左邊到右第一個數
textBox3.Text = b.ToString();//算式1中的從左邊到右第二個數
textBox4.Text = aaa.ToString();//算式2中的從左邊到右第一個數
textBox5.Text = bbb.ToString();//算式2中的從左邊到右第二個數
textBox6.Text = bb.ToString();//算式2中的從左邊到右第三個數
label2.Text = op;//算式1中的運算符號,隨機產生對應的符號
label1.Text = op1;//算式2中的運算符號,隨機產生對應的符號
label6.Text = op2;//算式2中的運算符號,隨機產生對應的符號
textBox1.Text="";//按鍵后清空文本框的內容!
textBox7.Text="";//按鍵后清空文本框的內容!
textBox1.Focus();
}
private void Button2Click(object sender, EventArgs e)
{
//if (textBox1.Text =="")
// MessageBox.Show("請輸入數字,不能為空");
//else
// MessageBox.Show("輸入的數字正確");
if (textBox1.Text == "")//判斷是否輸入的用戶名,如果沒有輸入,顯示下面的提示,否則跳到else
{
MessageBox.Show("答案不能為空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (textBox7.Text == "")//判斷是否輸入的用戶名,如果沒有輸入,顯示下面的提示,否則跳到else
{
MessageBox.Show("答案不能為空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
string str = textBox1.Text;//文本框輸入為等式的結果,結果答案輸入處。
string str1 = textBox7.Text;
double d = double.Parse(str);
double dd = double.Parse(str1);
string disp = " " + a + op + b + "=" + str + " ";
string disp1 = " " + aaa + op1 + bbb + op2 + bb + "=" + str1 + " ";
if (d == result) // if( Math.Abs(d-result)< 1e-3 )
disp += "√ 答案正確 劉穎穎你真棒";
else
disp += "╳ 答案錯誤 加油重新列算式運算";
if (dd == result2) // if( Math.Abs(d-result)< 1e-3 )
disp1 += "√ 答案正確 劉穎穎你真棒";
else
disp1 += "╳ 答案錯誤 加油重新列算式運算";
lstDisp.Items.Add(disp);
lstDisp.Items.Add(disp1);
textBox1.Text="";//清空上一次輸入的結果!
textBox7.Text="";//清空上一次輸入的結果!
}
}
void TextBox1KeyPress(object sender, KeyPressEventArgs e)
{
if(!(char.IsNumber(e.KeyChar))&& e.KeyChar !=(char)8)
{
e.Handled = true;//判定為數字,可以輸入
}
}
void LstDispSelectedIndexChanged(object sender, EventArgs e)
{
if (lstDisp.Text.Length >10)
lstDisp.Text = "";
}
void TextBox7KeyPress(object sender, KeyPressEventArgs e)
{
if(!(char.IsNumber(e.KeyChar))&& e.KeyChar !=(char)8)
{
e.Handled = true;//判定為數字,可以輸入
}
}
void Button3Click(object sender, EventArgs e)
{
lstDisp.Items.Clear();
}
}
}
復制代碼
全部資料51hei下載地址:
運算1.4版本.7z
(4.44 MB, 下載次數: 20)
2020-12-13 17:36 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
liuboyang2020
時間:
2020-11-30 00:56
怎么上傳附件
作者:
51hei團團
時間:
2020-12-2 05:46
liuboyang2020 發表于 2020-11-30 00:56
怎么上傳附件
點幫助:
http://m.raoushi.com/bbs/dpj-507-1.html
作者:
liuboyang8888
時間:
2021-8-7 15:06
不錯,學習了。實測可運行
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1