标签:
王硕朋,计科13-1,学号:130201124
2.基本功能
这次作业是四则运算,就是加减乘除之间运算,通俗简单。
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void Integerdivide()
{
String getmax = textMin.Text;
int minnum = Convert.ToInt32(getmax); //最小范围设定
String getmin = textMax.Text;
int maxnum = Convert.ToInt32(getmin); //最大范围设定
Random R = new Random(); //取随机数
int den1, den2, num1, num2;
den1 = R.Next(minnum, maxnum);
num1 = R.Next(minnum, den1);
den2 = R.Next(minnum, maxnum);
num2 = R.Next(minnum, den2);
if (den2 != 0)
list.Items.Add(den1 + "/" + "(" + den2 + ")" + "=");
else
{
list.Items.Add(den2 + "/" + "(" + den1 + ")" + "=");
}
}
public void Fractionadd()
{
String getmax = textMin.Text;
int minnum = Convert.ToInt32(getmax);
String getmin = textMax.Text;
int maxnum = Convert.ToInt32(getmin);
Random R = new Random();
int den1, den2, num1, num2;
den1 = R.Next(minnum, maxnum);
num1 = R.Next(minnum, den1);
den2 = R.Next(minnum, maxnum);
num2 = R.Next(minnum, den2);
if (den1 != 0)
{
if (den2 != 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "+" + "(" + num2 + "/" + den2 + ")" + "=");
}
else if (den2 == 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "+" + "(" + den2 + "/" + num2 + ")" + "=");
}
}
else
{
if (den2 != 0)
{
list.Items.Add("(" + den1 + "/" + num1 + ")" + "+" + "(" + num2 + "/" + den2 + ")" + "=");
}
else if (den2 == 0)
{
list.Items.Add("(" + den1 + "/" + num1 + ")" + "+" + "(" + den2 + "/" + num2 + ")" + "=");
}
}
}
public void Fractiondelete()
{
String getmax = textMin.Text;
int minnum = Convert.ToInt32(getmax);
String getmin = textMax.Text;
int maxnum = Convert.ToInt32(getmin);
Random R = new Random();
int den1, den2, num1, num2;
den1 = R.Next(minnum, maxnum);
num1 = R.Next(minnum, den1);
den2 = R.Next(minnum, maxnum);
num2 = R.Next(minnum, den2);
if (den1 != 0)
{
if (den2 != 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "-" + "(" + num2 + "/" + den2 + ")" + "=");
}
else if (den2 == 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "-" + "(" + den2 + "/" + num2 + ")" + "=");
}
}
else
{
if (den2 != 0)
{
list.Items.Add("(" + den1 + "/" + num1 + ")" + "-" + "(" + num2 + "-" + den2 + ")" + "=");
}
else if (den2 == 0)
{
list.Items.Add("(" + den1 + "/" + num1 + ")" + "-" + "(" + den2 + "/" + num2 + ")" + "=");
}
}
}
public void Fractionmultiply()
{
String getmax = textMin.Text;
int minnum = Convert.ToInt32(getmax);
String getmin = textMax.Text;
int maxnum = Convert.ToInt32(getmin);
Random R = new Random();
int den1, den2, num1, num2;
den1 = R.Next(minnum, maxnum);
num1 = R.Next(minnum, den1);
den2 = R.Next(minnum, maxnum);
num2 = R.Next(minnum, den2);
if (den1 != 0)
{
if (den2 != 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "*" + "(" + num2 + "/" + den2 + ")" + "=");
}
else if (den2 == 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "*" + "(" + den2 + "/" + num2 + ")" + "=");
}
}
else
{
if (den2 != 0)
{
list.Items.Add("(" + den1 + "/" + num1 + ")" + "*" + "(" + num2 + "/" + den2 + ")" + "=");
}
else if (den2 == 0)
{
list.Items.Add("(" + den1 + "/" + num1 + ")" + "*" + "(" + den2 + "/" + num2 + ")" + "=");
}
}
}
public void Fractiondivide()
{
String getmax = textMin.Text;
int minnum = Convert.ToInt32(getmax);
String getmin = textMax.Text;
int maxnum = Convert.ToInt32(getmin);
Random R = new Random();
int den1, den2, num1, num2;
den1 = R.Next(minnum, maxnum);
num1 = R.Next(minnum, den1);
den2 = R.Next(minnum, maxnum);
num2 = R.Next(minnum, den2);
if (den1 != 0)
{
if (den2 != 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "/" + "(" + num2 + "/" + den2 + ")" + "=");
}
else if (den2 == 0)
{
list.Items.Add("(" + num1 + "/" + den1 + ")" + "/" + "(" + den2 + "/" + num2 + ")" +