C编程实现计算器-1024.docxVIP

  • 2
  • 0
  • 约1.22万字
  • 约 16页
  • 2016-09-21 发布于重庆
  • 举报
C编程实现计算器-1024

?C#编程实现计算器分类:?/hongkaihua1987/article/category/856884C#2011-07-31 15:55?328人阅读?/hongkaihua1987/article/details/6648454评论(0)?javascript:void(0);收藏?/hongkaihua1987/article/details/6648454举报/tag/details.html?tag=textboxtextbox/tag/details.html?tag=%e7%bc%96%e7%a8%8b编程/tag/details.html?tag=c%23c#/tag/details.html?tag=buttonbutton/tag/details.html?tag=objectobject/tag/details.html?tag=radiobuttonradiobutton??Form1.cs 代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace calc{ public partial class Form1 : Form { Double total;? //计算的总值 Double before;? //输入运算符号之前的数字 Double dengBefore;? //单击等号之前取得文本框中的值 String str;? //运算符号的类型 Boolean isInputOperator = false;? //在输入数字之前是否输入了运算符 Boolean useJian = false;? //用于减号中 Boolean useCheng = false;? //用于乘号中 Boolean useChu = false;? //用于除号中 Boolean useDeng = false; //用于等号中 Boolean useContinueClic = false; //用于连续单击运算符号 Boolean useOne = false;? //用于一次运算结束 Boolean useOne2 = false;? //用于一次运算结束 Boolean useSpace = false; //用于退格 public Form1() { InitializeComponent(); btnpercent.Visible = false; btnDao.Visible = false; btnContrary.Visible = false; btn_sqrt.Visible = false; this.Height = 300; } //数字输入 把其它数字键绑定到零数字键上 private void button0_Click(object sender, EventArgs e) { Button btn = (Button)sender;?? if (btn != null) { if (textBox1.Text != 除数不能为零 textBox1.Text != 函数输入无效) { useOne2 = true; if (useOne == true useOne2 == true) { clear(); } if (isInputOperator == false)? //没有输入运算符号时 { if (textBox1.Text == 0) { textBox1.Text = ; textBox1.Text = textBox1.Text + btn.Text;?? } else { textBox1.Text = textBox1.Text + btn.Text; } } else? //输入运算符号时 { isInputOperator = false; textBox1.Text = ; textBox1.Text = textBox1.Text + btn.Text; } useContinueClic = false; useSpace = false; } } } //定义方法用于清空 public void clear() { total = 0; before = 0; dengBefore = 0; isInputOperator = false; useJian = false; useCheng = false; useChu = false; useDeng =

文档评论(0)

1亿VIP精品文档

相关文档