解决方案 »
- 如何实现刷帖、自动增加点击量的功能?
- C#新手,一个简单的问题 跪求高手进啊.....
- TcpClient.Connect(String, Int32)和TcpClient.Connect(IPAddress, Int32)的区别
- 点击树菜单的一个子菜单,插入时间……
- 菜鸟求助。。请问怎样在代码里设置字体透明度?????
- 下面代码执行后是否释放了堆栈空间?如果没有,请写出正确的释放方法。
- 升星散分,再问个比较迷茫的问题?
- 求助,WinForm和Wpf的invoke调用
- 循环层数不确定,怎么办?
- 新中新二代身份证的一些问题
- oracle数据库(datatable)
- blob类型数据存储问题,高手进!!
{
SeqStack<char> optr = new SeqStack <char>(20);
SeqStack<int> opnd = new SeqStack <int>(20);
optr.Push(‘#’);
char c = Console.Read();
char theta = 0;
int a = 0;
int b = 0;
while (c != ‘#’)
{
if((c!=’+’) && (c!=’-‘)
&& (c!=’*’) && (c!=’/’)
&& (c!=’(‘) && (c!=’)’{
optr.Push(c);
}
else
{
switch(Precede(optr.GetTop(), c))
{
Case ‘<’:
optr.Push(c);
c = Console.Read();
break;
case ‘=’:
optr.Pop();
c = Console.Read();
break;
case ‘>’:
theta = optr.Pop();
a = opnd.Pop();
b = opnd.Pop();
opnd.Push(Operate(a,theta,b));
break;
}
}
Precede判断运算符优先级。
object o = new DataTable().Compute(s, "");
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 计算器
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void timer1_Tick(object sender, EventArgs e)
{
time.Text = DateTime.Now.ToString();
} private void time_Click(object sender, EventArgs e)
{ } private double nPrevValue = 0; //上一次值
private bool bAppend = true; //用户按的数字是否连接在显示的数字后面
private string strPrevOpar = ""; //上一次的操作符号 // C按钮
private void button16_Click(object sender, EventArgs e)
{
tbShow.Text = "0";
strPrevOpar = "";
bAppend = true;
nPrevValue = 0;
} //处理数字键
private void Num_Click(object sender, System.EventArgs e)
{
string strNum = ((System.Windows.Forms.Button)sender).Text;
if (bAppend)
tbShow.Text = double.Parse(tbShow.Text + strNum).ToString();
else
{
tbShow.Text = strNum;
bAppend = true;
} } //操作符号
private void Opar_Click(object sender, EventArgs e)
{
double nCurValue = double.Parse(tbShow.Text);
switch (strPrevOpar)
{
case "+":
nCurValue += nPrevValue;
break;
case "-":
nCurValue = nPrevValue - nCurValue;
break;
case "*":
nCurValue *= nPrevValue;
break;
case "/":
nCurValue = nPrevValue / nCurValue;
break;
case "sqrt":
nCurValue = nCurValue * nCurValue;
break; default:
break;
}
strPrevOpar = ((System.Windows.Forms.Button)sender).Text;
bAppend = false;
tbShow.Text = nCurValue.ToString();
nPrevValue = nCurValue; } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
} private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("版本号:1.0.0.0 "); } private void 作者ToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("作者:");
} private void Form1_Load(object sender, EventArgs e)
{ } private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.tbShow.SelectAll();
this.tbShow.Copy();
} private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.tbShow.Paste();
} private void dot_Click(object sender, EventArgs e)
{
string strNum = ((System.Windows.Forms.Button)sender).Text;
tbShow.Text = tbShow.Text + strNum;
}