我用windows控制台编写了一个计算器,如何在输入数字时,让数字从右向左显示呢?
这里是主要的程序代码部分,请哪位高手指点一下,本人对编程不是很了解,先谢谢了using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 计算器
{
public partial class Form1 : Form
{
double a { get; set; }
double b { get; set; }
double c { get; set; }
string opt { get; set; }
public Form1()
{
InitializeComponent();
}
private void num_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
this.container.Text += btn.Text;
}
private void opt_Click(object sender, EventArgs e)
{
a = Convert.ToDouble(this.container.Text);
Button btn = (Button)sender;
opt = btn.Text;
this.container.Text = "";
}
private void c_Click(object sender, EventArgs e)
{
b = Convert.ToDouble(this.container .Text );
switch (opt)
{
case "+":
c = a + b;
break;
case "-": c = a - b;
break;
case "*": c = a * b;
break;
case "/": c = a / b;
break;
case "%": c = a % b;
break;
case "1/x": c = 1 / a;
break;
}
this.container.Text = c.ToString();
}
}
}