二柱子在线答题
Posted mengweile
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了二柱子在线答题相关的知识,希望对你有一定的参考价值。
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;
using System.IO;
namespace 软工
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int[] ans = new int[30];
int [] number = new int[60];
Random random = new Random();
for(int i=0;i<60;i++)
{
number[i] = random.Next(0, 100);
}
for (int i = 0; i < 30; i++)
{
int a = random.Next(0, 3);
if (number[i + 30] != 0 && (number[i] % number[i + 30]) == 0)
{
textBox4.AppendText(number[i] + "/" + number[i + 30] + "=" + "
");
ans[i] = number[i] / number[i + 30];
textBox1.AppendText(Convert.ToString(ans[i]) + "
");
}
else if (a == 1)
{
textBox4.AppendText(number[i] + "-" + number[i + 30] + "=" + "
");
ans[i] = number[i] - number[i + 30];
textBox1.AppendText(Convert.ToString(ans[i]) + "
");
}
else if (a == 0)
{
textBox4.AppendText(number[i] + "*" + number[i + 30] + "=" + "
");
ans[i] = number[i] * number[i + 30];
textBox1.AppendText(Convert.ToString(ans[i]) + "
");
}
else
{
textBox4.AppendText(number[i] + "+" + number[i + 30] + "=" + "
");
ans[i] = number[i] + number[i + 30];
textBox1.AppendText(Convert.ToString(ans[i]) + "
");
}
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Visible = true;
string s = textBox5.Text;
string[] ss = s.Split(new char[1] { ‘
‘ }, StringSplitOptions.RemoveEmptyEntries);
string a = textBox1.Text;
string[] ans = a.Split(new char[1] { ‘
‘ }, StringSplitOptions.RemoveEmptyEntries);
if (ss.Length < 30)
{
MessageBox.Show("未答完题!");
return;
}
for (int i = 0; i < 30; i++)
{
if (ss[i] == null)
{
MessageBox.Show("有空答案");
return;
}
}
for (int i = 0; i < 30; i++)
{
if (Convert.ToInt32 ( ss[i]) ==Convert.ToInt32 (ans[i]))
textBox6.AppendText("正确" + "
");
if (Convert.ToInt32(ss[i]) != Convert.ToInt32(ans[i]))
textBox6.AppendText("错误" + "
");
}
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button3_Click(object sender, EventArgs e)
{
SaveFileDialog sfile = new SaveFileDialog();
sfile.Filter = "错题本|*.text";
if(sfile.ShowDialog()==DialogResult.OK )
{
StreamWriter sw = new StreamWriter(sfile.FileName);
sw.WriteLine(textBox4.Text);
sw.Close();
以上是关于二柱子在线答题的主要内容,如果未能解决你的问题,请参考以下文章