拼吾爱程序人生.Net编程C# 数据结构中用C#实现“表达式计算”

1  /  1  页   1 跳转 查看:963

数据结构中用C#实现“表达式计算”

数据结构中用C#实现“表达式计算”

文/佚名  出处/中国IT实验室

用C#重新回温一下,加深一点印象.

  目前还不支持单目操作符,只支持双目的,以后改进吧.:)

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Expression1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtInfix;
private System.Windows.Forms.TextBox txtPostfix;
private System.Windows.Forms.Button btnPostfix;
private System.Windows.Forms.Button btnCalc;
private System.Windows.Forms.TextBox txtCalc;
/// <summary>
/// 必需的设计器变量。
/// </summary>
  private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
  InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
  }
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
  protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

 感谢原创者的辛勤劳动,希望对您有所帮助,转载请注明原出处。
 您可能对 [C#] 的这些文章也感兴趣:

C#下实现动态系统托盘图标
C# 对象深拷贝、浅铐贝、直接拷贝
删除DataTable中的重复行
C# 或Asp.Net 将excel表格导入数据库
C# 3.0 之新特性总结
NET框架与网络服务(上)
C#4.0新特性之二:Named and Optional Parameters (2) 剖析篇
用.Net开发Windows服务初探
C# wm6通过udp协议和pc通讯
用C#实现木马程序(分析)
 

回复:数据结构中用C#实现“表达式计算”

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
  private void InitializeComponent()
{
this.txtInfix = new System.Windows.Forms.TextBox();
this.txtPostfix = new System.Windows.Forms.TextBox();
this.btnPostfix = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnCalc = new System.Windows.Forms.Button();
this.txtCalc = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtInfix
//
  this.txtInfix.Location = new System.Drawing.Point(88, 24);
this.txtInfix.Name = "txtInfix";
this.txtInfix.Size = new System.Drawing.Size(176, 21);
this.txtInfix.TabIndex = 0;
this.txtInfix.Text = "";
//
// txtPostfix
//
  this.txtPostfix.Location = new System.Drawing.Point(88, 88);
this.txtPostfix.Name = "txtPostfix";
this.txtPostfix.Size = new System.Drawing.Size(176, 21);
this.txtPostfix.TabIndex = 1;
this.txtPostfix.Text = "";
//
// btnPostfix
//
  this.btnPostfix.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnPostfix.Location = new System.Drawing.Point(120, 56);
this.btnPostfix.Name = "btnPostfix";
this.btnPostfix.TabIndex = 2;
this.btnPostfix.Text = "转化";
this.btnPostfix.Click += new System.EventHandler(this.btnPostfix_Click);
//
// label1
//
  this.label1.Location = new System.Drawing.Point(8, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 3;
this.label1.Text = "中缀表达式";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
  this.label2.Location = new System.Drawing.Point(8, 88);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 4;
this.label2.Text = "后缀表达式";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnCalc
//
  this.btnCalc.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnCalc.Location = new System.Drawing.Point(24, 136);
this.btnCalc.Name = "btnCalc";
this.btnCalc.TabIndex = 5;
this.btnCalc.Text = "计算结果";
this.btnCalc.Click += new System.EventHandler(this.btnCalc_Click);
//
// txtCalc
//
  this.txtCalc.Location = new System.Drawing.Point(120, 136);
this.txtCalc.Name = "txtCalc";
this.txtCalc.Size = new System.Drawing.Size(144, 21);
this.txtCalc.TabIndex = 6;
this.txtCalc.Text = "";
//
// Form1
//
  this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 182);
this.Controls.Add(this.txtCalc);
this.Controls.Add(this.btnCalc);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnPostfix);
this.Controls.Add(this.txtPostfix);
this.Controls.Add(this.txtInfix);
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "表达式计算";
this.ResumeLayout(false);
}

#endregion
 
1  /  1  页   1 跳转

快速回复帖子

标题
禁用 URL 识别
禁用表情
禁用 Discuz!NT 代码
使用个人签名
  [完成后可按 Ctrl+Enter 无刷新发布]  

版权所有 拼吾爱程序人生    Total Unique Visitors:

web counter

Powered by Discuz!NT 2.1.202   Copyright © 2001-2008 Comsenz Inc. 鄂ICP备07500843号
返顶部