标签:
1、asp需要改的地方不少啊,id这一地方就耗费20多分钟-----
2.代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
///chouxiang 的摘要说明
/// </summary>
abstract class wuyu
{
public class Operation
{
private double numberA = 0;
private double numberB = 0;
public double NumberA
{
get { return numberA; }
set { numberA = value; }
}
public double NumberB
{
get { return numberB; }
set { numberB = value; }
}
}
public abstract double xiaole(double a, double b);
}
class jiafa : wuyu
{
public override double xiaole(double a, double b)
{
return a + b;
}
}
class jianfa : wuyu
{
public override double xiaole(double a, double b)
{
return a - b;
}
}
class chengfa : wuyu
{
public override double xiaole(double a, double b)
{
return a * b;
}
}
class chufa : wuyu
{
public override double xiaole(double a, double b)
{
return a / b;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
///operation 的摘要说明
/// </summary>
public class operation
{
wuyu ww=null;
public operation(string fuhao)
{
switch(fuhao)
{
case"+":
jiafa g = new jiafa();
ww = g;
break;
case "-":
jianfa u = new jianfa();
ww = u;
break;
case "*":
chengfa a = new chengfa();
ww = a;
break;
case "/":
chufa n = new chufa();
ww = n;
break;
}
}
public double result(double a,double b)
{
return ww.xiaole(a,b);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text.RegularExpressions;
public partial class _Default : System.Web.UI.Page
{
public int i;
public static int count;
public static int right;
protected void Page_Load(object sender, EventArgs e)
{
}
public void duqu()
{
string path = @"D:\\计算存储.txt";
string[] line = File.ReadAllLines(path);
if (i < line.Length)
{
TextBox1.Text = line[i];
}
else
{
Response.Write("已经做完");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
duqu();
}
protected void Button3_Click(object sender, EventArgs e)
{
duqu();
i++;
string xx = TextBox1.Text;
string ss = @"(\d+)(\S+)+(\d+)";
Match mast = Regex.Match(xx, ss);
///这正则表达式无解了
int strNumberA = int.Parse(mast.Groups[1].Value);
string strNumberC = mast.Groups[2].Value;
int strNumberB = int.Parse(mast.Groups[3].Value);
double x = Convert.ToDouble(strNumberA);
string z =TextBox2.Text;
double y = Convert.ToDouble(strNumberB);
operation op = new operation(strNumberC);
double res = op.result(x, y);
string daan = Convert.ToString(res);
if (daan == z)
{
Response.Write("恭喜哈,你对了");
right++;
}
else
{
Response.Write("sfasdf"+daan);
}
TextBox2.Text = "";
count++;
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox4.Text = right.ToString();
TextBox5.Text = count.ToString();
TextBox7.Text = ((right / (double)(count)) * 100).ToString() + "%";
}
}



标签:
原文地址:http://www.cnblogs.com/mctianyou/p/4998221.html