实例介绍
【实例截图】
【核心代码】
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace 多功能计算机器 { public class Form : System.Windows.Forms.Form { private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox expressBox; private System.ComponentModel.Container components = null; //***往下为自已定义的变量*** //定义存放运算符(包括:' ','-',...,'sin',...,'arcsin',...,'(',...等)及其特性的数据结构 public struct opTable //定义存放运算符及其优先级和单双目的结构 { public string op; //用于存放运算符 op为oprater的简写 public int code; //用存放运算符的优先级 public char grade; //用于判断存放的运算符是单目还是双目 } public opTable[] opchTbl=new opTable[19]; //用于存放制定好的运算符及其特性(优先级和单双目)的运算符表,其初始化在方法Initialize()中 public opTable[] operateStack=new opTable[30]; //用于存放从键盘扫描的运算符的栈 //定义优先级列表 1,2,3,4,5,6,7,8,9, public int[]osp=new int[19]{6,6,6,6,6,6,6,6,6,6,6,5,3,3,2,2,7,0,1}; //数组中元素依次为: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/"," ","-","(",")","" 的栈外(因为有的运算符是从右向左计算,有的是从左往右计算,用内外优先级可以限制其执行顺序)优先级 public int[]isp=new int[18]{5,5,5,5,5,5,5,5,5,5,5,4,3,3,2,2,1,1}; //数组中元素依次为: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/"," ","-","(" ,"end" 的栈内(因为有的运算符是从右向左计算,有的是从左往右计算,用内外优先级可以限制其执行顺序)优先级 //定义存放从键盘扫描的数据的栈 public double[]dataStack=new double[30]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //定义表态指针 public int opTop=-1; //指向存放(从键盘扫描的)运算符栈的指针 public int dataTop=-1;//指向存放(从键盘扫描的)数据栈指针 //定义存放从键盘输入的起始字符串 public string startString; public int startTop=0; public double variableX=0; public double variableY=0; const double PI=3.1415926; int number=1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button6; private System.Windows.Forms.Button button7; private System.Windows.Forms.Button button8; private System.Windows.Forms.Button button9; private System.Windows.Forms.Button button10; private System.Windows.Forms.Button button11; private System.Windows.Forms.Button button12; private System.Windows.Forms.Button button13; private System.Windows.Forms.Button button14; private System.Windows.Forms.Button button15; private System.Windows.Forms.Button button16; private System.Windows.Forms.Button button17; private System.Windows.Forms.Button button18; private System.Windows.Forms.Button button19; private System.Windows.Forms.Button button20; private System.Windows.Forms.Button button21; private System.Windows.Forms.Button button22; private System.Windows.Forms.Button button23; private System.Windows.Forms.Button button24; private System.Windows.Forms.Button button25; private System.Windows.Forms.Button button26; private System.Windows.Forms.Button button27; private System.Windows.Forms.Button button28; private System.Windows.Forms.Button button29; private System.Windows.Forms.Button button30; private System.Windows.Forms.Button button31; private System.Windows.Forms.Button button32; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox endbox; private System.Windows.Forms.Button button33; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox endList; private System.Windows.Forms.Button button34; private System.Windows.Forms.Button button35; private System.Windows.Forms.Button button40; public int startTopMoveCount=0; //******* //int x=0; #region Windows Form Designer generated code public Form() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #endregion #region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.expressBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.button7 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); this.button9 = new System.Windows.Forms.Button(); this.button10 = new System.Windows.Forms.Button(); this.button11 = new System.Windows.Forms.Button(); this.button12 = new System.Windows.Forms.Button(); this.button13 = new System.Windows.Forms.Button(); this.button14 = new System.Windows.Forms.Button(); this.button15 = new System.Windows.Forms.Button(); this.button16 = new System.Windows.Forms.Button(); this.button17 = new System.Windows.Forms.Button(); this.button18 = new System.Windows.Forms.Button(); this.button19 = new System.Windows.Forms.Button(); this.button20 = new System.Windows.Forms.Button(); this.button21 = new System.Windows.Forms.Button(); this.button22 = new System.Windows.Forms.Button(); this.button23 = new System.Windows.Forms.Button(); this.button24 = new System.Windows.Forms.Button(); this.button25 = new System.Windows.Forms.Button(); this.button26 = new System.Windows.Forms.Button(); this.button27 = new System.Windows.Forms.Button(); this.button28 = new System.Windows.Forms.Button(); this.button29 = new System.Windows.Forms.Button(); this.button30 = new System.Windows.Forms.Button(); this.button31 = new System.Windows.Forms.Button(); this.button32 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.endbox = new System.Windows.Forms.TextBox(); this.button33 = new System.Windows.Forms.Button(); this.endList = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.button34 = new System.Windows.Forms.Button(); this.button35 = new System.Windows.Forms.Button(); this.button40 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // expressBox // this.expressBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.expressBox.Location = new System.Drawing.Point(112, 32); this.expressBox.Name = "expressBox"; this.expressBox.Size = new System.Drawing.Size(288, 21); this.expressBox.TabIndex = 0; this.expressBox.Text = ""; this.expressBox.TextChanged = new System.EventHandler(this.expressBox_TextChanged); // // label2 // this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.label2.Location = new System.Drawing.Point(16, 32); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(88, 24); this.label2.TabIndex = 6; this.label2.Text = "请输入表达式:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.label2.Click = new System.EventHandler(this.label2_Click); // // button1 // this.button1.ForeColor = System.Drawing.SystemColors.HotTrack; this.button1.Location = new System.Drawing.Point(216, 288); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(32, 23); this.button1.TabIndex = 8; this.button1.Text = "1"; this.button1.Click = new System.EventHandler(this.button1_Click_1); // // button2 // this.button2.ForeColor = System.Drawing.SystemColors.HotTrack; this.button2.Location = new System.Drawing.Point(216, 248); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(32, 23); this.button2.TabIndex = 9; this.button2.Text = "4"; this.button2.Click = new System.EventHandler(this.button2_Click_1); // // button3 // this.button3.ForeColor = System.Drawing.SystemColors.HotTrack; this.button3.Location = new System.Drawing.Point(328, 288); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(32, 23); this.button3.TabIndex = 10; this.button3.Text = "3"; this.button3.Click = new System.EventHandler(this.button3_Click); // // button4 // this.button4.ForeColor = System.Drawing.SystemColors.HotTrack; this.button4.Location = new System.Drawing.Point(272, 288); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(32, 23); this.button4.TabIndex = 11; this.button4.Text = "2"; this.button4.Click = new System.EventHandler(this.button4_Click); // // button5 // this.button5.ForeColor = System.Drawing.SystemColors.HotTrack; this.button5.Location = new System.Drawing.Point(272, 248); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(32, 23); this.button5.TabIndex = 12; this.button5.Text = "5"; this.button5.Click = new System.EventHandler(this.button5_Click); // // button6 // this.button6.ForeColor = System.Drawing.SystemColors.HotTrack; this.button6.Location = new System.Drawing.Point(328, 248); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(32, 23); this.button6.TabIndex = 13; this.button6.Text = "6"; this.button6.Click = new System.EventHandler(this.button6_Click); // // button7 // this.button7.ForeColor = System.Drawing.SystemColors.HotTrack; this.button7.Location = new System.Drawing.Point(328, 208); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(32, 23); this.button7.TabIndex = 14; this.button7.Text = "9"; this.button7.Click = new System.EventHandler(this.button7_Click); // // button8 // this.button8.ForeColor = System.Drawing.SystemColors.HotTrack; this.button8.Location = new System.Drawing.Point(272, 208); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(32, 23); this.button8.TabIndex = 15; this.button8.Text = "8"; this.button8.Click = new System.EventHandler(this.button8_Click); // // button9 // this.button9.ForeColor = System.Drawing.SystemColors.HotTrack; this.button9.Location = new System.Drawing.Point(216, 208); this.button9.Name = "button9"; this.button9.Size = new System.Drawing.Size(32, 23); this.button9.TabIndex = 16; this.button9.Text = "7"; this.button9.Click = new System.EventHandler(this.button9_Click); // // button10 // this.button10.ForeColor = System.Drawing.SystemColors.HotTrack; this.button10.Location = new System.Drawing.Point(216, 328); this.button10.Name = "button10"; this.button10.Size = new System.Drawing.Size(32, 23); this.button10.TabIndex = 17; this.button10.Text = "0"; this.button10.Click = new System.EventHandler(this.button10_Click); // // button11 // this.button11.ForeColor = System.Drawing.SystemColors.HotTrack; this.button11.Location = new System.Drawing.Point(272, 328); this.button11.Name = "button11"; this.button11.Size = new System.Drawing.Size(32, 23); this.button11.TabIndex = 18; this.button11.Text = "DEL"; this.button11.Click = new System.EventHandler(this.button11_Click); // // button12 // this.button12.ForeColor = System.Drawing.SystemColors.HotTrack; this.button12.Location = new System.Drawing.Point(384, 248); this.button12.Name = "button12"; this.button12.Size = new System.Drawing.Size(32, 23); this.button12.TabIndex = 19; this.button12.Text = "*"; this.button12.Click = new System.EventHandler(this.button12_Click); // // button13 // this.button13.ForeColor = System.Drawing.SystemColors.HotTrack; this.button13.Location = new System.Drawing.Point(432, 248); this.button13.Name = "button13"; this.button13.Size = new System.Drawing.Size(32, 23); this.button13.TabIndex = 20; this.button13.Text = "/"; this.button13.Click = new System.EventHandler(this.button13_Click); // // button14 // this.button14.ForeColor = System.Drawing.SystemColors.HotTrack; this.button14.Location = new System.Drawing.Point(384, 288); this.button14.Name = "button14"; this.button14.Size = new System.Drawing.Size(32, 23); this.button14.TabIndex = 21; this.button14.Text = " "; this.button14.Click = new System.EventHandler(this.button14_Click); // // button15 // this.button15.ForeColor = System.Drawing.SystemColors.HotTrack; this.button15.Location = new System.Drawing.Point(432, 288); this.button15.Name = "button15"; this.button15.Size = new System.Drawing.Size(32, 23); this.button15.TabIndex = 22; this.button15.Text = "-"; this.button15.Click = new System.EventHandler(this.button15_Click); // // button16 // this.button16.BackColor = System.Drawing.SystemColors.InactiveCaption; this.button16.ForeColor = System.Drawing.SystemColors.HotTrack; this.button16.Location = new System.Drawing.Point(24, 208); this.button16.Name = "button16"; this.button16.Size = new System.Drawing.Size(32, 23); this.button16.TabIndex = 23; this.button16.Text = "Sin"; this.button16.Click = new System.EventHandler(this.button16_Click); // // button17 // this.button17.ForeColor = System.Drawing.SystemColors.HotTrack; this.button17.Location = new System.Drawing.Point(24, 248); this.button17.Name = "button17"; this.button17.Size = new System.Drawing.Size(32, 23); this.button17.TabIndex = 24; this.button17.Text = "Cos"; this.button17.Click = new System.EventHandler(this.button17_Click); // // button18 // this.button18.ForeColor = System.Drawing.SystemColors.HotTrack; this.button18.Location = new System.Drawing.Point(24, 288); this.button18.Name = "button18"; this.button18.Size = new System.Drawing.Size(32, 23); this.button18.TabIndex = 25; this.button18.Text = "Tan"; this.button18.Click = new System.EventHandler(this.button18_Click); // // button19 // this.button19.ForeColor = System.Drawing.SystemColors.HotTrack; this.button19.Location = new System.Drawing.Point(24, 328); this.button19.Name = "button19"; this.button19.Size = new System.Drawing.Size(32, 23); this.button19.TabIndex = 26; this.button19.Text = "Cot"; this.button19.Click = new System.EventHandler(this.button19_Click); // // button20 // this.button20.ForeColor = System.Drawing.SystemColors.HotTrack; this.button20.Location = new System.Drawing.Point(64, 208); this.button20.Name = "button20"; this.button20.Size = new System.Drawing.Size(56, 23); this.button20.TabIndex = 27; this.button20.Text = "ArcSin"; this.button20.Click = new System.EventHandler(this.button20_Click); // // button21 // this.button21.ForeColor = System.Drawing.SystemColors.HotTrack; this.button21.Location = new System.Drawing.Point(64, 248); this.button21.Name = "button21"; this.button21.Size = new System.Drawing.Size(56, 23); this.button21.TabIndex = 28; this.button21.Text = "ArcCos"; this.button21.Click = new System.EventHandler(this.button21_Click); // // button22 // this.button22.ForeColor = System.Drawing.SystemColors.HotTrack; this.button22.Location = new System.Drawing.Point(64, 288); this.button22.Name = "button22"; this.button22.Size = new System.Drawing.Size(56, 23); this.button22.TabIndex = 29; this.button22.Text = "ArcTan"; this.button22.Click = new System.EventHandler(this.button22_Click); // // button23 // this.button23.ForeColor = System.Drawing.SystemColors.HotTrack; this.button23.Location = new System.Drawing.Point(64, 328); this.button23.Name = "button23"; this.button23.Size = new System.Drawing.Size(56, 23); this.button23.TabIndex = 30; this.button23.Text = "ArcCot"; this.button23.Click = new System.EventHandler(this.button23_Click); // // button24 // this.button24.ForeColor = System.Drawing.SystemColors.HotTrack; this.button24.Location = new System.Drawing.Point(136, 208); this.button24.Name = "button24"; this.button24.Size = new System.Drawing.Size(32, 23); this.button24.TabIndex = 31; this.button24.Text = "Sec"; this.button24.Click = new System.EventHandler(this.button24_Click); // // button25 // this.button25.ForeColor = System.Drawing.SystemColors.HotTrack; this.button25.Location = new System.Drawing.Point(136, 248); this.button25.Name = "button25"; this.button25.Size = new System.Drawing.Size(32, 23); this.button25.TabIndex = 32; this.button25.Text = "Csc"; this.button25.Click = new System.EventHandler(this.button25_Click); // // button26 // this.button26.ForeColor = System.Drawing.SystemColors.HotTrack; this.button26.Location = new System.Drawing.Point(136, 288); this.button26.Name = "button26"; this.button26.Size = new System.Drawing.Size(32, 23); this.button26.TabIndex = 33; this.button26.Text = "Ln"; this.button26.Click = new System.EventHandler(this.button26_Click); // // button27 // this.button27.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.button27.ForeColor = System.Drawing.SystemColors.HotTrack; this.button27.Location = new System.Drawing.Point(320, 328); this.button27.Name = "button27"; this.button27.Size = new System.Drawing.Size(48, 23); this.button27.TabIndex = 34; this.button27.Text = "次方"; this.button27.Click = new System.EventHandler(this.button27_Click); // // button28 // this.button28.ForeColor = System.Drawing.SystemColors.HotTrack; this.button28.Location = new System.Drawing.Point(432, 208); this.button28.Name = "button28"; this.button28.Size = new System.Drawing.Size(32, 23); this.button28.TabIndex = 35; this.button28.Text = ")"; this.button28.Click = new System.EventHandler(this.button28_Click); // // button29 // this.button29.ForeColor = System.Drawing.SystemColors.HotTrack; this.button29.Location = new System.Drawing.Point(384, 208); this.button29.Name = "button29"; this.button29.Size = new System.Drawing.Size(32, 23); this.button29.TabIndex = 36; this.button29.Text = "("; this.button29.Click = new System.EventHandler(this.button29_Click); // // button30 // this.button30.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.button30.ForeColor = System.Drawing.SystemColors.HotTrack; this.button30.Location = new System.Drawing.Point(384, 328); this.button30.Name = "button30"; this.button30.Size = new System.Drawing.Size(80, 23); this.button30.TabIndex = 37; this.button30.Text = "=="; this.button30.Click = new System.EventHandler(this.button30_Click); // // button31 // this.button31.BackColor = System.Drawing.SystemColors.InactiveCaption; this.button31.ForeColor = System.Drawing.Color.Black; this.button31.Location = new System.Drawing.Point(328, 168); this.button31.Name = "button31"; this.button31.Size = new System.Drawing.Size(96, 23); this.button31.TabIndex = 38; this.button31.Text = "Back Space"; this.button31.Click = new System.EventHandler(this.button31_Click); // // button32 // this.button32.BackColor = System.Drawing.SystemColors.InactiveCaptionText; this.button32.ForeColor = System.Drawing.SystemColors.ControlText; this.button32.Location = new System.Drawing.Point(432, 168); this.button32.Name = "button32"; this.button32.Size = new System.Drawing.Size(32, 23); this.button32.TabIndex = 39; this.button32.Text = "CE"; this.button32.Click = new System.EventHandler(this.button32_Click); // // label1 // this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.label1.Location = new System.Drawing.Point(40, 72); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(64, 20); this.label1.TabIndex = 40; this.label1.Text = "计算结果:"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // endbox // this.endbox.Anchor = System.Windows.Forms.AnchorStyles.Left; this.endbox.Location = new System.Drawing.Point(112, 72); this.endbox.Name = "endbox"; this.endbox.Size = new System.Drawing.Size(136, 21); this.endbox.TabIndex = 41; this.endbox.Text = "0.000000"; // // button33 // this.button33.ForeColor = System.Drawing.SystemColors.HotTrack; this.button33.Location = new System.Drawing.Point(136, 328); this.button33.Name = "button33"; this.button33.Size = new System.Drawing.Size(32, 23); this.button33.TabIndex = 42; this.button33.Text = "Л"; this.button33.Click = new System.EventHandler(this.button33_Click); // // endList // this.endList.Location = new System.Drawing.Point(112, 112); this.endList.Multiline = true; this.endList.Name = "endList"; this.endList.Size = new System.Drawing.Size(352, 21); this.endList.TabIndex = 43; this.endList.Tag = "ff"; this.endList.Text = ""; this.endList.TextChanged = new System.EventHandler(this.endList_TextChanged); // // label3 // this.label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.label3.Location = new System.Drawing.Point(40, 112); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(64, 20); this.label3.TabIndex = 44; this.label3.Text = "结果列表:"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.label3.Click = new System.EventHandler(this.label3_Click); // // button34 // this.button34.ForeColor = System.Drawing.SystemColors.ControlText; this.button34.Location = new System.Drawing.Point(24, 168); this.button34.Name = "button34"; this.button34.Size = new System.Drawing.Size(96, 23); this.button34.TabIndex = 45; this.button34.Text = "清除结果列表"; this.button34.Click = new System.EventHandler(this.button34_Click); // // button35 // this.button35.Location = new System.Drawing.Point(408, 72); this.button35.Name = "button35"; this.button35.Size = new System.Drawing.Size(56, 23); this.button35.TabIndex = 46; this.button35.Text = "帮助"; this.button35.Click = new System.EventHandler(this.button35_Click); // // button40 // this.button40.Location = new System.Drawing.Point(408, 32); this.button40.Name = "button40"; this.button40.Size = new System.Drawing.Size(56, 23); this.button40.TabIndex = 54; this.button40.Text = "重写"; this.button40.Click = new System.EventHandler(this.button40_Click); // // Form // this.AcceptButton = this.button30; this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.BackColor = System.Drawing.SystemColors.InactiveCaption; this.ClientSize = new System.Drawing.Size(488, 390); this.Controls.Add(this.button40); this.Controls.Add(this.button35); this.Controls.Add(this.button34); this.Controls.Add(this.label3); this.Controls.Add(this.endList); this.Controls.Add(this.button33); this.Controls.Add(this.endbox); this.Controls.Add(this.label1); this.Controls.Add(this.button32); this.Controls.Add(this.button31); this.Controls.Add(this.button30); this.Controls.Add(this.button29); this.Controls.Add(this.button28); this.Controls.Add(this.button27); this.Controls.Add(this.button26); this.Controls.Add(this.button25); this.Controls.Add(this.button24); this.Controls.Add(this.button23); this.Controls.Add(this.button22); this.Controls.Add(this.button21); this.Controls.Add(this.button20); this.Controls.Add(this.button19); this.Controls.Add(this.button18); this.Controls.Add(this.button17); this.Controls.Add(this.button16); this.Controls.Add(this.button15); this.Controls.Add(this.button14); this.Controls.Add(this.button13); this.Controls.Add(this.button12); this.Controls.Add(this.button11); this.Controls.Add(this.button10); this.Controls.Add(this.button9); this.Controls.Add(this.button8); this.Controls.Add(this.button7); this.Controls.Add(this.button6); this.Controls.Add(this.button5); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.label2); this.Controls.Add(this.expressBox); this.MaximizeBox = false; this.Name = "Form"; this.Text = "多功能计算器"; this.Load = new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form()); } private void Form1_Load(object sender, System.EventArgs e) { } private void Form_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { //label3.Text="X: " e.X.ToString() " ,Y: " e.Y.ToString(); } /*private void button1_Click(object sender, System.EventArgs e) { StartExcute(); } private void button2_Click(object sender, System.EventArgs e) { Application.Exit(); }*/ private void expressBox_TextChanged(object sender, System.EventArgs e) { } public void InitializeOpchTblStack() //制定运算符及其特性(优先级和单双目)的运算符表 { //public int[]osp={6,6,6,6,6,6,6,6,6,6,6,5,3,3,2,2,7,0,1}; //数组中元素依次为: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/"," ","-","(",")","" 的栈外(因为有的运算符是从右向左计算,有的是从左往右计算,用内外优先级可以限制其执行顺序)优先级 //public int[]isp={5,5,5,5,5,5,5,5,5,5,5,4,3,3,2,2,1,1}; //数组中元素依次为: "sin","cos","tan","cot","arcsin","arccos","arctan","sec","csc","ln","^","*","/"," ","-","(","end" 的栈内(因为有的运算符是从右向左计算,有的是从左往右计算,用内外优先级可以限制其执行顺序)优先级 opchTbl[0].op="sin"; opchTbl[0].code=1; opchTbl[0].grade='s'; opchTbl[1].op="cos"; opchTbl[1].code=2; opchTbl[1].grade='s'; opchTbl[2].op="tan"; opchTbl[2].code=3; opchTbl[2].grade='s'; opchTbl[3].op="cot"; opchTbl[3].code=4; opchTbl[3].grade='s'; opchTbl[4].op="arcsin"; opchTbl[4].code=5; opchTbl[4].grade='s'; opchTbl[5].op="arccos"; opchTbl[5].code=6; opchTbl[5].grade='s'; opchTbl[6].op="arctan"; opchTbl[6].code=7; opchTbl[6].grade='s'; opchTbl[7].op="arccot"; opchTbl[7].code=8; opchTbl[7].grade='s'; opchTbl[8].op="sec"; opchTbl[8].code=9; opchTbl[8].grade='s'; opchTbl[9].op="csc"; opchTbl[9].code=10; opchTbl[9].grade='s'; opchTbl[10].op="ln"; opchTbl[10].code=11; opchTbl[10].grade='s'; opchTbl[11].op="^"; opchTbl[11].code=12; opchTbl[11].grade='d'; opchTbl[12].op="*"; opchTbl[12].code=13; opchTbl[12].grade='d'; opchTbl[13].op="/"; opchTbl[13].code=14; opchTbl[13].grade='d'; opchTbl[14].op=" "; opchTbl[14].code=15; opchTbl[14].grade='d'; opchTbl[15].op="-"; opchTbl[15].code=16; opchTbl[15].grade='d'; opchTbl[16].op="("; opchTbl[16].code=17; opchTbl[16].grade='d'; opchTbl[17].op=")"; opchTbl[17].code=18; opchTbl[17].grade='d'; opchTbl[18].op=" "; opchTbl[18].code=19; opchTbl[18].grade='d'; startString=expressBox.Text; //将输入的运算表达式存入"起始字符串" //dataStack.Initialize(); operateStack.Initialize(); } public void CreterionFaction() { //以下为消去待扫描字符串中的所有空格字符 for(int i=0;i<startString.Length;i ) if(startString[i].Equals(' ')) { startString=startString.Remove(i,1); i--; } //以下代码使待扫描字符串的单目(' '和'-')变为双目 if(startString.Length!=0) if(startString[0]==' '||startString[0]=='-') { startString=startString.Insert(0,"0"); } for(int i=0;i<startString.Length-1;i ) { if((startString[i]=='(')&&(startString[i 1]=='-')) startString=startString.Insert(i 1,"0"); } startString=startString.Insert(startString.Length,")"); //将待扫描字符串字号字母转化为小写字母 startString=startString.ToLower(); ////**试验用语句 //label4.Text=startString; } public bool CheckParentthese() //检查括号是否匹配 { int number=0; for(int i=0;i<startString.Length-1;i ) { if(i=='(') number ; if(i==')') number--; if(number<0) return false; } if(number!=0) { return false; } return true; } public int CheckFollowCorrect() //给运算表达式分块(三角函数...算术运算符等),再根据其返回值来检验其属于哪类错误 { string str,oldString="",newString=""; int dataCount=0,characterCount=0; if(startString.Equals(")")) return 0; //输入字符串为空返回值 if((startString[0]=='*')||(startString[0]=='/')||(startString[0]=='^')||(startString[0]==')')) return 11; //首字符输入错误返回值 for(int i=0;i<startString.Length;i ) { if((oldString.Equals("三角函数"))&&(newString.Equals("右括号"))) return 2; //三角函数直接接右括号错误返回值 if((oldString.Equals("左括号"))&&(newString.Equals("算术运算符"))) return 3; //左括号直接接算术运算符错误返回值 if((oldString.Equals("数字序列"))&&(newString.Equals("三角函数"))) return 4; //数字序列后直接接三角函数错误返回值 if((oldString.Equals("数字序列"))&&(newString.Equals("左括号"))) return 5; //数字序列后直接接左括号错误返回值 if((oldString.Equals("算术运算符"))&&(newString.Equals("右括号"))) return 6; //算术运算符后直接接右括号错误返回值 if((oldString.Equals("右括号"))&&(newString.Equals("左括号"))) return 7; //右括号直接接左括号错误返回值 if((oldString.Equals("右括号"))&&(newString.Equals("三角函数"))) return 8; //右括号直接接三角函数错误返回值 if((oldString.Equals("数字序列"))&&(newString.Equals("数字序列"))) return 9; //数字序列后直接接'pi'/'e'或'pi'/'e'直接接数字序列错误返回值 if((oldString.Equals("算术运算符"))&&(newString.Equals("算术运算符"))) return 10; //算术运算符后直接接算术运算符错误返回值 oldString=newString; if(i<startString.Length-5&&startString.Length>=6) { str=startString.Substring(i,6); if((str.CompareTo("arcsin")==0)||(str.CompareTo("arccos")==0)||(str.CompareTo("arctan")==0)||(str.CompareTo("arccot")==0)) { newString="三角函数"; i =5; characterCount ; continue; } } if(i<startString.Length-2&&startString.Length>=3) { str=startString.Substring(i,3); if((str.CompareTo("sin")==0)||(str.CompareTo("cos")==0)||(str.CompareTo("tan")==0)||(str.CompareTo("cot")==0)||(str.CompareTo("sec")==0)||(str.CompareTo("csc")==0)) { newString="三角函数"; i =2; characterCount ; continue; } } if(i<(startString.Length-1)&&(startString.Length)>=2) { str=startString.Substring(i,2); if(str.CompareTo("ln")==0) { newString="三角函数"; i =1; characterCount ; continue; } if(str.CompareTo("pi")==0) { newString="数字序列"; i =1;dataCount ; continue; } } str=startString.Substring(i,1); if(str.Equals("^")||str.Equals("*")||str.Equals("/")||str.Equals(" ")||str.Equals("-")) { newString="算术运算符"; characterCount ; continue; } if(str.Equals("e")) { newString="数字序列"; dataCount ; continue; } /*if(str.Equals("x")) { newString="数字序列"; dataCount ; continue; }*/ if(str.Equals("(")) { newString="左括号"; characterCount ; continue; } if(str.Equals(")")) { newString="右括号"; characterCount ; continue; } if(Char.IsDigit(startString[i])) { while(Char.IsDigit(startString[i])) { i ; } if(startString[i]=='.'&&(!Char.IsDigit(startString[i 1]))&&(i 1)!=startString.Length) return 13; if(startString[i]=='.') { i ; } while(Char.IsDigit(startString[i])) { i ; } newString="数字序列"; i--; dataCount ; continue; } return 1; //非法字符 } if((dataCount==0&&characterCount!=0)||(startString[0]=='0'&&dataCount==1&&characterCount>1&&startString.Length!=2)) return 12; return 100; } public int IsCharacterOrData(ref double num) { string str=""; startTop =startTopMoveCount; startTopMoveCount=0; int i=startTop; if(i<startString.Length-5&&startString.Length>=6) { str=startString.Substring(i,6); for(int j=4;j<=7;j ) if(str.Equals(opchTbl[j].op)) { startTopMoveCount=6; return opchTbl[j].code; } } if(i<startString.Length-2&&startString.Length>=3) { str=startString.Substring(i,3); for(int j=0;j<10;j ) if(str.CompareTo(opchTbl[j].op)==0) { startTopMoveCount=3; return opchTbl[j].code; } } if(i<(startString.Length-1)&&(startString.Length)>=2) { str=startString.Substring(i,2); if(str.CompareTo("ln")==0) { startTopMoveCount=2; return 11; } if(str.CompareTo("pi")==0) { startTopMoveCount=2; num=Math.PI; return 100; } } //以下开始确认一个字符是属于什么值类型 if(i<startString.Length) { str=startString.Substring(i,1); for(int j=11;j<19;j ) { if(str.Equals(opchTbl[j].op)) {startTopMoveCount=1;return opchTbl[j].code;} } if(str.CompareTo("e")==0) { startTopMoveCount=1; num=Math.E; return 100; } /*if(str.CompareTo("x")==0) { startTopMoveCount=1; num=variableX; return 100; }*/ if(Char.IsDigit(startString[i])) { double temp=0,M=10; int j=i; while(Char.IsDigit(startString[j])) { temp=M*temp Char.GetNumericValue(startString[j]); startTop ; j ; } if(startString[j]=='.') { j ;startTop ; } while(Char.IsDigit(startString[j])) { temp =1.0/M*Char.GetNumericValue(startString[j]); M/=10;j ; startTop ; } startTopMoveCount=0; num=temp; return 100; } } return -1; } public double DoubleCount(string opString,double data1,double data2) { //双目运算 if(opString.CompareTo(" ")==0) return (data1 data2); if(opString.CompareTo("-")==0) return (data1-data2); if(opString.CompareTo("*")==0) return (data1*data2); if(opString.CompareTo("/")==0) return (data1/data2); if(opString.CompareTo("^")==0) { double end=data1; for(int i=0;i<data2-1;i ) end*=data1; return (end); } return Double.MaxValue; //定义域不对,返回 } public double DoubleCount(string opString,double data1) { //单目运算 if(opString.CompareTo("sin")==0) return Math.Sin(data1); if(opString.CompareTo("cos")==0) return Math.Cos(data1); if(opString.CompareTo("tan")==0) return Math.Tan(data1); if(opString.CompareTo("cot")==0) return (1/(Math.Tan(data1))); if(opString.CompareTo("arcsin")==0) if(-1<=data1&&data1<=1) return Math.Asin(data1); if(opString.CompareTo("arccos")==0) if(-1<=data1&&data1<=1) return Math.Acos(data1); if(opString.CompareTo("arctan")==0) if(-Math.PI/2<=data1&&data1<=Math.PI/2)return Math.Atan(data1); if(opString.CompareTo("arccot")==0) if(-Math.PI/2<=data1&&data1<=Math.PI/2)return (-Math.Atan(data1)); if(opString.CompareTo("sec")==0) return (1/(Math.Cos(data1))); if(opString.CompareTo("csc")==0) return (1/(Math.Sin(data1))); if(data1>0) if(opString.CompareTo("ln")==0) return Math.Log(data1); return Double.MaxValue; //定义域不对 } public bool CountValueY(ref double tempY) //方法功能为求得解 { int type=-1; //存放正在扫描的字符串是为数字类型还是(单双目运算符) double num=0; //如果是数据,则返回数据的值 //进栈底结束符"end" opTop ; operateStack[opTop].op="end"; operateStack[opTop].code=18; operateStack[opTop].grade=' '; while(startTop<=startString.Length-1) { start: type=IsCharacterOrData(ref num); //调用判断返回值类型函数 //if(type==17) ; if(type==-1){return false;} if(type==100) { dataTop=dataTop 1; //Console.WriteLine(dataTop); dataStack[dataTop]=num; } else { if(osp[type-1]>isp[operateStack[opTop].code-1]) //操作符进栈 { opTop ; operateStack[opTop].op=opchTbl[type-1].op; operateStack[opTop].code=opchTbl[type-1].code; operateStack[opTop].grade=opchTbl[type-1].grade; } else { while(osp[type-1]<=isp[operateStack[opTop].code-1]) //弹出操作符跟数据计算,并存入数据 { if(operateStack[opTop].op.CompareTo("end")==0)//当遇到"end"结束符表示已经获得结果 { if(dataTop==0) { tempY=dataStack[dataTop]; startTop=0; startTopMoveCount=0; opTop=-1; dataTop=-1; return true; } else return false; //运算符和数据的个数不匹配造成的错误 } if(operateStack[opTop].op.CompareTo("(")==0) //如果要弹出操作数为'( ',则消去左括号 { opTop--; goto start; } //弹出操作码和一个或两个数据计算,并将计算结果存入数据栈 double data1,data2; opTable operate; if(dataTop>=0) data2=dataStack[dataTop]; else return false; operate.op=operateStack[opTop].op; operate.code=operateStack[opTop].code; operate.grade=operateStack[opTop].grade; opTop--; //处理一次,指针必须仅且只能下移一个单位 if(operate.grade=='d') { if(dataTop-1>=0) data1=dataStack[dataTop-1]; else return false; double tempValue=DoubleCount(operate.op,data1,data2); if(tempValue!=Double.MaxValue) dataStack[--dataTop]=tempValue; else return false; } if(operate.grade=='s') { double tempValue=DoubleCount(operate.op,data2); if(tempValue!=Double.MaxValue) dataStack[dataTop]=tempValue; else return false; } } //如果当前栈外操作符比栈顶的操作符优先级别高,则栈外操作符进栈 opTop ; operateStack[opTop].op=opchTbl[type-1].op; operateStack[opTop].code=opchTbl[type-1].code; operateStack[opTop].grade=opchTbl[type-1].grade; } } } return false; } public void StartExcute() { InitializeOpchTblStack(); CreterionFaction(); if(CheckParentthese()==false) { MessageBox.Show("括号不匹配,请重新输入!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } switch(CheckFollowCorrect()) { case 0: MessageBox.Show("表达式为空,请先输入表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; case 1: MessageBox.Show("表达式中有非法字符!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 2: MessageBox.Show("三角函数运算符与 ) 之间应输入数据或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 3: MessageBox.Show("' ( ' 与算术运算符之间应输入数据或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 4: MessageBox.Show("数字数列与三角函数之间应输入算术运算符或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 5: MessageBox.Show("数字数列与 ' ( ' 之间应输入算术运算符或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 6: MessageBox.Show("算术运算符与右括号之间应输入数据或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 7: MessageBox.Show("' ) ' 与 ' ( ' 之间应输入算术运算符或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 8: MessageBox.Show("' ) ' 与三角函数之间应输入算术运算符或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 9: MessageBox.Show("常量 ' PI ' 或 ' E ' 或 ' X ' 与数字数据之间应输入算术运算符或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);return; case 10: MessageBox.Show("算术运算符与算术运算符之间应输入数据或其它表达式!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 11: MessageBox.Show("表达式头部不能为' ', ' - ' , ' * ' , ' / ' , ' ^ ' ,' ) '!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 12: MessageBox.Show("仅有运算符号没有数字数据或数据缺少而无法计算,请输入数字数据!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; case 13: MessageBox.Show("小数点后面缺少小数部分,请输入小数部分!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } double tempY=0; switch(CountValueY(ref tempY)) { case false:MessageBox.Show("输入的表达式不正确或反三角函数定义域在其定义域范围之外!!!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } endbox.Text=tempY.ToString();//依次存档计算结果 endList.Text ="("; endList.Text =number; endList.Text ="). "; number ; endList.Text =endbox.Text; endList.Text =" "; } private void label4_Click(object sender, System.EventArgs e) { } private void label2_Click(object sender, System.EventArgs e) { } private void button30_Click(object sender, System.EventArgs e) { StartExcute(); } private void button10_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button10.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button11_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,"."); expressBox.SelectionStart=expressBox.TextLength; } private void button27_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,"^"); expressBox.SelectionStart=expressBox.TextLength; } private void button1_Click_1(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button1.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button4_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button4.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button3_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button3.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button2_Click_1(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button2.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button14_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button14.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button15_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button15.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button5_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button5.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button6_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button6.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button9_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button9.Text); expressBox.SelectionStart=expressBox.TextLength; //expressBox.SelectionStart =button9.Text.Length; } private void button8_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button8.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button7_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button7.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button12_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button12.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button13_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button13.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button29_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button29.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button28_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button28.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button16_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button16.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button20_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button20.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button17_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button17.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button21_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button21.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button24_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button24.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button18_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button18.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button22_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button22.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button25_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button25.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button19_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button19.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button23_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button23.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button26_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,button26.Text); expressBox.SelectionStart=expressBox.TextLength; } private void button31_Click(object sender, System.EventArgs e) { if(expressBox.Text.Length>0) expressBox.Text=expressBox.Text.Remove(expressBox.Text.Length-1,1); } private void button32_Click(object sender, System.EventArgs e) { expressBox.Text=""; endbox.Text="0.000000"; } private void button33_Click(object sender, System.EventArgs e) { expressBox.SelectedText=null; expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,"PI"); expressBox.SelectionStart=expressBox.TextLength; } private void button34_Click(object sender, System.EventArgs e) { endList.Text=""; number=1; } private void button35_Click(object sender, System.EventArgs e) { MessageBox.Show("\n\n数学常用字符表示如下:\n Л: PI\n 常量E: e或E\n CE: 清零\n\n在输入角度时直接输入角度值:\n 例如 sin30 中的30表示度数,结果为1/2.\n\n请用鼠标直接点击或用键盘输入表达式.\n","Help",MessageBoxButtons.OK,MessageBoxIcon.Question); } private void button36_Click(object sender, System.EventArgs e) { double temp=double.Parse(endbox.Text); if(temp<=double.MaxValue) { temp=temp*Math.PI/180; // textBox1.Text=temp.ToString(); } } private void button37_Click(object sender, System.EventArgs e) { double temp=double.Parse(endbox.Text.ToString()); temp=temp*180/Math.PI; // textBox2.Text=temp.ToString(); } private void button38_Click(object sender, System.EventArgs e) { //expressBox.Text=textBox1.Text; // expressBox.SelectedText=null; // expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,textBox1.Text); // expressBox.SelectionStart=expressBox.TextLength; } private void button39_Click(object sender, System.EventArgs e) { //expressBox.Text=textBox2.Text; // expressBox.SelectedText=null; // expressBox.Text=expressBox.Text.Insert(expressBox.SelectionStart,textBox2.Text); // expressBox.SelectionStart=expressBox.TextLength; } private void button40_Click(object sender, System.EventArgs e) { expressBox.Text=""; } private void endList_TextChanged(object sender, System.EventArgs e) { } private void label3_Click(object sender, System.EventArgs e) { } } }
标签: 多功能计算器
网友评论
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
支持(0) 盖楼(回复)
支持(0) 盖楼(回复)