⑴ C#窗口計算器代碼

很簡單的啊,你找個值SUM記錄1+2的結果 初值為0,判斷如果為0 就做1+2.如果不為0就做SUM+2,這樣一直按等於就自己加啊

java算24點代碼:輸入4個數算24點,能夠在命令提示符下就可以運行。100多

import java.util.Scanner;

/** 給定4個數字計算24 */
public class Core {

private double expressionResult = 24;
// private int maxLine=10;
private boolean error = true;
private double numbers[] = new double[4];
public Object resultReturn;

/**
* 該對象擁有3個私有變數 expressionResult,所需結果 maxLine,輸出結果每頁行數 error,是否出錯
* numbers[4],記錄用來運算的4個數
*
* 其次,該對象擁有以下方法供外部調用 setNumbers(double[] <運算的數>) 輸入用來運算的數,4個時才能計算,無返回
* setMaxLine(int <行數>) 輸入每頁的行數,無返回 getMaxLine() 返回每頁的行數,類型為int
* setExpressionResult(double <所需結果>) 輸入所需結果,無返回 getExpressionResult()
* 返回所需結果,類型為double getExpression() 返回可得出所需結果的表達式,類型為字元串數組
*
* 最後,私有方法均為計算與表達式轉換部分
*/

// 測試使用
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] arr = new int[4];
System.out.print("輸入第一個數:");
arr[0] = scanner.nextInt();
System.out.print("輸入第二個數:");
arr[1] = scanner.nextInt();
System.out.print("輸入第三個數:");
arr[2] = scanner.nextInt();
System.out.print("輸入第四個數:");
arr[3] = scanner.nextInt();
Core s = new Core();
s.setNumbers(arr);
String[] output = s.getExpression();
for (int i = 0; i < output.length; i++) {
System.out.println(output[i]);
}
}

/** 設定被計算的四個數,由於是數組,所以具有容錯功能(不為4個數) */
public void setNumbers(double[] n) {
if (n.length == 4) {
error = false;
numbers = n;
} else
error = true;
}

public void setNumbers(int[] n) {
if (n.length == 4) {
error = false;
for (int i = 0; i < 4; i++) {
numbers[i] = n[i];
}
} else
error = true;
}

/** 設定每頁顯示的行數 */
// public void setMaxLine(int n) {
// if (n>0) {
// maxLine=n;
// }
// }
// /** 返回每頁顯示的行數 */
// public int getMaxLine() {
// return maxLine;
// }
/** 設定需要得到的結果 */
public void setExpressionResult(double n) {
expressionResult = n;
}

/** 返回所需結果 */
public double expressionResult() {
return expressionResult;
}

/** 返回符合條件的表達式 */
public String[] getExpression() {
if (!error) {
String[] expression = calculate(numbers);
return expression;
} else
return new String[] { "出錯了,輸入有誤" };
}

/** cal24(),輸出結果為24的表達式 */
private String[] calculate(double[] n) {
if (n.length != 4)
return new String[] { "Error" };
double[] n1 = new double[3];
double[] n2 = new double[2];
String[] resultString = new String[1024]; // 最多1000組解,暫時未溢出
int count = 0;
boolean isRepeat = false;
for (int t1 = 0; t1 < 6; t1++) {
for (int c1 = 0; c1 < 6; c1++) {
for (int t2 = 0; t2 < 3; t2++) {
for (int c2 = 0; c2 < 6; c2++) {
for (int c3 = 0; c3 < 6; c3++) {
if ((c1 / 3 == c2 / 3 && (c1 % 3) * (c2 % 3) != 0)
|| (c2 / 3 == c3 / 3 && (c2 % 3) * (c3 % 3) != 0)
|| (c1 / 3 == c3 / 3
&& (c1 % 3) * (c3 % 3) != 0 && t2 == 2)) {
// 去除連減連除的解,因為x/(y/z)=x*z/y
continue;
}
n1 = cal1(n, t1, c1);
n2 = cal2(n1, t2, c2);
double result = cal(n2[0], n2[1], c3);
if ((result - expressionResult) < 0.00000001
&& (expressionResult - result) < 0.00000001) {
resultString[count] = calString(n, t1, c1, t2,
c2, c3)
+ "=" + (int) expressionResult;
for (int i = 0; i < count; i++) {
isRepeat = false;
if (resultString[i]
.equals(resultString[count])) { // 去除完全重復的解
isRepeat = true;
break; // 提前退出循環
}
}
if (c1 == c2 && c2 == c3 && c1 % 3 == 0
&& t1 + t2 != 0) { // 連加連乘
isRepeat = true;
}
if (!isRepeat) {
count++;
}
}
}
}
}
}
}
if (count == 0)
return new String[] { "該組數無解" };
String[] resultReturn = new String[count];
System.array(resultString, 0, resultReturn, 0, count);
return resultReturn;
}

/** cal1(),將4個數計算一次後返回3個數 */
private double[] cal1(double[] n, int t, int c) { // t為原來的t1,c為原來的c1
double[] m = new double[3];
switch (t) {
case 0:
m[1] = n[2];
m[2] = n[3];
m[0] = cal(n[0], n[1], c);
break;
case 1:
m[1] = n[1];
m[2] = n[3];
m[0] = cal(n[0], n[2], c);
break;
case 2:
m[1] = n[1];
m[2] = n[2];
m[0] = cal(n[0], n[3], c);
break;
case 3:
m[1] = n[0];
m[2] = n[3];
m[0] = cal(n[1], n[2], c);
break;
case 4:
m[1] = n[0];
m[2] = n[2];
m[0] = cal(n[1], n[3], c);
break;
default:
m[1] = n[0];
m[2] = n[1];
m[0] = cal(n[2], n[3], c);
}
return m;
}

/** cal2(),將3個數計算一次後返回2個數 */
private double[] cal2(double[] n, int t, int c) { // t為原來的t2,c為原來的c2
double[] m = new double[2];
switch (t) {
case 0:
m[1] = n[2];
m[0] = cal(n[0], n[1], c);
break;
case 1:
m[1] = n[1];
m[0] = cal(n[0], n[2], c);
break;
default:
m[1] = n[0];
m[0] = cal(n[1], n[2], c);
}
return m;
}

/** cal(),將2個數計算後返回結果 */
private double cal(double n1, double n2, int c) { // n1,n2為運算數,c為運算類型
switch (c) {
case 0:
return n1 + n2;
case 1:
return n1 - n2;
case 2:
return n2 - n1;
case 3:
return n1 * n2;
case 4:
if (n2 == 0)
return 9999; // 使計算結果必不為24
else
return n1 / n2;
default:
if (n1 == 0)
return 9999; // 同上
else
return n2 / n1;
}
}

/** calString(),輸出表達式 */
private String calString(double[] n, int t1, int c1, int t2, int c2, int c3) {
String[] nString = new String[4];
switch (t1) {
case 0:
nString[0] = calString2("" + (int) n[0], "" + (int) n[1], c1);
nString[1] = "" + (int) n[2];
nString[2] = "" + (int) n[3];
break;
case 1:
nString[0] = calString2("" + (int) n[0], "" + (int) n[2], c1);
nString[1] = "" + (int) n[1];
nString[2] = "" + (int) n[3];
break;
case 2:
nString[0] = calString2("" + (int) n[0], "" + (int) n[3], c1);
nString[1] = "" + (int) n[1];
nString[2] = "" + (int) n[2];
break;
case 3:
nString[0] = calString2("" + (int) n[1], "" + (int) n[2], c1);
nString[1] = "" + (int) n[0];
nString[2] = "" + (int) n[3];
break;
case 4:
nString[0] = calString2("" + (int) n[1], "" + (int) n[3], c1);
nString[1] = "" + (int) n[0];
nString[2] = "" + (int) n[2];
break;
default:
nString[0] = calString2("" + (int) n[2], "" + (int) n[3], c1);
nString[1] = "" + (int) n[0];
nString[2] = "" + (int) n[1];
}
if ((c2 / 3 > c1 / 3 && (t2 != 2 || c2 / 3 == c3 / 3))
|| ((c3 / 3 > c1 / 3 + c2 / 3) && t2 == 2)
|| (c3 == 1 && c1 / 3 == 0)) // 特定情況下加上一個括弧*****************************
nString[0] = '(' + nString[0] + ')';
switch (t2) {
case 0:
nString[0] = calString2(nString[0], "" + nString[1], c2);
nString[1] = nString[2];
break;
case 1:
nString[0] = calString2(nString[0], nString[2], c2);
break;
default:
nString[3] = nString[0];
nString[0] = calString2(nString[1], nString[2], c2);
nString[1] = nString[3];
}
if (c3 / 3 > c2 / 3 || (c3 == 2 && nString[0].indexOf('+') >= 0)) // 特定情況下加上一個括弧*****************************
nString[0] = '(' + nString[0] + ')';
return calString2(nString[0], nString[1], c3);
}

/** calString(),根據符號輸出一部運算表達式 */
private String calString2(String n1, String n2, int c) {
switch (c) {
case 0:
return n1 + '+' + n2;
case 1:
return n1 + '-' + n2;
case 2:
return n2 + '-' + n1;
case 3:
return n1 + '*' + n2;
case 4:
return n1 + '/' + n2;
default:
return n2 + '/' + n1;
}
}
}

⑶ C#實現計算器,可以連加、連減、連乘、連除;能實現混合運算 郵箱:[email protected]

以下代碼可作為初學C#的朋友學習借鑒,技術無止境,希望以下的代碼能起到拋磚引玉的作用。using System;
using System.Windows.Forms;
using System.Drawing;
publicclass win:Form {
Button[] b =new Button[10];
Button bDot,bPlus,bSub,bMul,bDiv,bEqu,bClr;
Panel panCalc;
TextBox txtCalc;
Double dblAcc;
Double dblSec;
bool blnClear,blnFrstOpen;
String strOper;
public win() {
try {
this.Text="Calculator";
panCalc=new Panel();
txtCalc =new TextBox();
txtCalc.Location =new Point(10,10);
txtCalc.Size=new Size(150,10);
txtCalc.ReadOnly=true;
txtCalc.RightToLeft=RightToLeft.Yes;
panCalc.Size=new Size(200,200);
panCalc.BackColor=Color.Aqua;
panCalc.Controls.Add(txtCalc);
addButtons(panCalc);
this.Size=new Size(200,225);
this.Controls.Add(panCalc);
dblAcc=0;
dblSec=0;
blnFrstOpen=true;
blnClear=false;
strOper=new String('=',1);
}
catch (Exception e) {
Console.WriteLine("error ...... "+ e.StackTrace);
}
}
privatevoid addButtons(Panel p) {
for (int i=0;i<=9;i++) {
b[i]=new Button();
b[i].Text=Convert.ToString(i);
b[i].Size=new Size(25,25);
b[i].BackColor=Color.White;
b[i].Click+=new EventHandler(btn_clk);
p.Controls.Add(b[i]);
}
b[0].Location=new Point(10,160);
b[1].Location=new Point(10,120);
b[4].Location=new Point(10,80);
b[7].Location=new Point(10,40);
b[2].Location=new Point(50,120);
b[5].Location=new Point(50,80);
b[8].Location=new Point(50,40);
b[3].Location=new Point(90,120);
b[6].Location=new Point(90,80);
b[9].Location=new Point(90,40);
bDot=new Button();
bDot.Size=new Size(25,25);
bDot.Location=new Point(50,160);
bDot.BackColor=Color.White;
bDot.Text=".";
bDot.Click+=new EventHandler(btn_clk);
bPlus=new Button();
bPlus.Size=new Size(25,25);
bPlus.Location=new Point(130,160);
bPlus.BackColor=Color.White;
bPlus.Text="+";
bPlus.Click+=new EventHandler(btn_Oper);
bSub=new Button();
bSub.Size=new Size(25,25);
bSub.Location=new Point(130,120);
bSub.BackColor=Color.White;
bSub.Text="-";
bSub.Click+=new EventHandler(btn_Oper);
bMul=new Button();
bMul.Size=new Size(25,25);
bMul.Location=new Point(130,80);
bMul.BackColor=Color.White;
bMul.Text="*";
bMul.Click+=new EventHandler(btn_Oper);
bDiv=new Button();
bDiv.Size=new Size(25,25);
bDiv.Location=new Point(130,40);
bDiv.BackColor=Color.White;
bDiv.Text="/";
bDiv.Click+=new EventHandler(btn_Oper);
bEqu=new Button();
bEqu.Size=new Size(25,25);
bEqu.Location=new Point(90,160);
bEqu.BackColor=Color.White;
bEqu.Text="=";
bEqu.Click+=new EventHandler(btn_equ);
bClr=new Button();
bClr.Size=new Size(20,45);
bClr.Location=new Point(170,40);
bClr.BackColor=Color.Orange;
bClr.Text="AC";
bClr.Click+=new EventHandler(btn_clr);
p.Controls.Add(bDot);
p.Controls.Add(bPlus);
p.Controls.Add(bSub);
p.Controls.Add(bMul);
p.Controls.Add(bDiv);
p.Controls.Add(bEqu);
p.Controls.Add(bClr);
}
privatevoid btn_clk(object obj,EventArgs ea) {
if(blnClear)
txtCalc.Text="";
Button b3=(Button)obj;
txtCalc.Text+=b3.Text;
if (txtCalc.Text==".")
txtCalc.Text="0.";
dblSec=Convert.ToDouble(txtCalc.Text);
blnClear=false;
}
privatestaticvoid Main() {
Application.Run(new win());
}
privatevoid btn_Oper(object obj,EventArgs ea) {
Button tmp=(Button)obj;
strOper=tmp.Text;
if (blnFrstOpen)
dblAcc=dblSec;
else calc();
blnFrstOpen=false;
blnClear=true;
}
privatevoid btn_clr(object obj,EventArgs ea) {
clear();
}
privatevoid btn_equ(object obj,EventArgs ea) {
calc();
}
privatevoid calc() {
switch(strOper) {
case"+":
dblAcc+=dblSec;
break;
case"-":
dblAcc-=dblSec;
break;
case"*":
dblAcc*=dblSec;
break;
case"/":
dblAcc/=dblSec;
break;
}
strOper="=";
blnFrstOpen=true;
txtCalc.Text=Convert.ToString(dblAcc);
dblSec=dblAcc;
}
privatevoid clear() {
dblAcc=0;
dblSec=0;
blnFrstOpen=true;
txtCalc.Text="";
txtCalc.Focus();
}
}

⑷ 計算器上怎樣算連加連乘或連減連除的

就是3+2,+2,+2.唄
類似這種代碼:
等於號被按下:
如果(最後一次運算符=「+」)
編輯框3.內容=編輯框3.內容+編輯框2.內容
--------
具體你的源碼是怎麼寫的俺不清楚,照上面的格式寫就可以了。

⑸ 用C語言做一個可進行加減乘除的400位計算器(求思路)

這個可以用一位全加器的思路解決,用一個我有不限位數加法的C語言代碼,做ACM的時候的,你再聯想一下就可以寫出來了。

思路,用一個大數組,一位一位的加。

代碼:

#include<stdio.h>

intmain()

{

inta[240]={0},b[240]={0},c[241]={0};

inti,ka,kb,k;

chara1[240],b1[240];

gets(a1);

ka=strlen(a1);

gets(b1);

kb=strlen(b1);

if(ka>=kb)k=ka;

elsek=kb;

for(i=0;i<ka;i++)

a[i]=a1[ka-i-1]-'0';

for(i=0;i<kb;i++)

b[i]=b1[kb-i-1]-'0';

for(i=0;i<k;i++)

{

c[i]=a[i]+b[i]+c[i];

c[i+1]=c[i+1]+c[i]/10;

c[i]=c[i]%10;

}

if(c[k])k++;

for(i=k-1;i>=0;i--)

printf("%d",c[i]);

getchar();

return0;

}

這個只有240位,你可以將數組改大點,但是C必須比加數多一位,否則溢出。

樓上幾位太不給力了啊,不知道從哪兒粘貼來MFC的代碼,還是工程文件中的一個子文件。。。這根本編譯不通的,有本事直接把界面一起拷貝給提問者算了。。。

附上運行結果:

⑹ delphi計算器的自加。。。連加連減連乘連除

你的「=」只處理了單次,怎麼能計算出連續的加減乘除呢?
如果想要學習編程思路
http://www.qqgb.com/Program/Delphi/DelphiSource/Program_58628.html
下載慢慢研究

⑺ 問什麼這個程序連加可以,但是連減,連乘,連除不對呢

你把代碼粘出來

⑻ 求Java簡單計算器代碼(加減乘除就可以了,但能連加、連減、連乘、連除,小數零點幾也可以輸入)

要GUI嗎?
有郵件吧?隨便做了一個,發給你啊

⑼ 急求 JAVA的 算24點的代碼!進來看!有特別要求!

package ceshi;

/** 給定4個數字計算24 */
public class Core {

private double expressionResult = 24;
// private int maxLine=10;
private boolean error = true;
private double numbers[] = new double[4];
public Object resultReturn;

/**
* 該對象擁有3個私有變數 expressionResult,所需結果 maxLine,輸出結果每頁行數 error,是否出錯
* numbers[4],記錄用來運算的4個數
*
* 其次,該對象擁有以下方法供外部調用 setNumbers(double[] <運算的數>) 輸入用來運算的數,4個時才能計算,無返回
* setMaxLine(int <行數>) 輸入每頁的行數,無返回 getMaxLine() 返回每頁的行數,類型為int
* setExpressionResult(double <所需結果>) 輸入所需結果,無返回 getExpressionResult()
* 返回所需結果,類型為double getExpression() 返回可得出所需結果的表達式,類型為字元串數組
*
* 最後,私有方法均為計算與表達式轉換部分
*/

// 測試使用
public static void main(String[] args) {
Core s = new Core();
s.setNumbers(new int[] { 3, 4, 8, 6 });
String[] output = s.getExpression();
for (int i = 0; i < output.length; i++) {
System.out.println(output[i]);
}
}

/** 設定被計算的四個數,由於是數組,所以具有容錯功能(不為4個數) */
public void setNumbers(double[] n) {
if (n.length == 4) {
error = false;
numbers = n;
} else
error = true;
}

public void setNumbers(int[] n) {
if (n.length == 4) {
error = false;
for (int i = 0; i < 4; i++) {
numbers[i] = n[i];
}
} else
error = true;
}

/** 設定每頁顯示的行數 */
// public void setMaxLine(int n) {
// if (n>0) {
// maxLine=n;
// }
// }
// /** 返回每頁顯示的行數 */
// public int getMaxLine() {
// return maxLine;
// }
/** 設定需要得到的結果 */
public void setExpressionResult(double n) {
expressionResult = n;
}

/** 返回所需結果 */
public double expressionResult() {
return expressionResult;
}

/** 返回符合條件的表達式 */
public String[] getExpression() {
if (!error) {
String[] expression = calculate(numbers);
return expression;
} else
return new String[] { "出錯了,輸入有誤" };
}

/** cal24(),輸出結果為24的表達式 */
private String[] calculate(double[] n) {
if (n.length != 4)
return new String[] { "Error" };
double[] n1 = new double[3];
double[] n2 = new double[2];
String[] resultString = new String[1024]; // 最多1000組解,暫時未溢出
int count = 0;
boolean isRepeat = false;
for (int t1 = 0; t1 < 6; t1++) {
for (int c1 = 0; c1 < 6; c1++) {
for (int t2 = 0; t2 < 3; t2++) {
for (int c2 = 0; c2 < 6; c2++) {
for (int c3 = 0; c3 < 6; c3++) {
if ((c1 / 3 == c2 / 3 && (c1 % 3) * (c2 % 3) != 0)
|| (c2 / 3 == c3 / 3 && (c2 % 3) * (c3 % 3) != 0)
|| (c1 / 3 == c3 / 3
&& (c1 % 3) * (c3 % 3) != 0 && t2 == 2)) {
// 去除連減連除的解,因為x/(y/z)=x*z/y
continue;
}
n1 = cal1(n, t1, c1);
n2 = cal2(n1, t2, c2);
double result = cal(n2[0], n2[1], c3);
if ((result - expressionResult) < 0.00000001
&& (expressionResult - result) < 0.00000001) {
resultString[count] = calString(n, t1, c1, t2,
c2, c3)
+ "=" + (int) expressionResult;
for (int i = 0; i < count; i++) {
isRepeat = false;
if (resultString[i]
.equals(resultString[count])) { // 去除完全重復的解
isRepeat = true;
break; // 提前退出循環
}
}
if (c1 == c2 && c2 == c3 && c1 % 3 == 0
&& t1 + t2 != 0) { // 連加連乘
isRepeat = true;
}
if (!isRepeat) {
count++;
}
}
}
}
}
}
}
if (count == 0)
return new String[] { "該組數無解" };
String[] resultReturn = new String[count];
System.array(resultString, 0, resultReturn, 0, count);
return resultReturn;
}

/** cal1(),將4個數計算一次後返回3個數 */
private double[] cal1(double[] n, int t, int c) { // t為原來的t1,c為原來的c1
double[] m = new double[3];
switch (t) {
case 0:
m[1] = n[2];
m[2] = n[3];
m[0] = cal(n[0], n[1], c);
break;
case 1:
m[1] = n[1];
m[2] = n[3];
m[0] = cal(n[0], n[2], c);
break;
case 2:
m[1] = n[1];
m[2] = n[2];
m[0] = cal(n[0], n[3], c);
break;
case 3:
m[1] = n[0];
m[2] = n[3];
m[0] = cal(n[1], n[2], c);
break;
case 4:
m[1] = n[0];
m[2] = n[2];
m[0] = cal(n[1], n[3], c);
break;
default:
m[1] = n[0];
m[2] = n[1];
m[0] = cal(n[2], n[3], c);
}
return m;
}

/** cal2(),將3個數計算一次後返回2個數 */
private double[] cal2(double[] n, int t, int c) { // t為原來的t2,c為原來的c2
double[] m = new double[2];
switch (t) {
case 0:
m[1] = n[2];
m[0] = cal(n[0], n[1], c);
break;
case 1:
m[1] = n[1];
m[0] = cal(n[0], n[2], c);
break;
default:
m[1] = n[0];
m[0] = cal(n[1], n[2], c);
}
return m;
}

/** cal(),將2個數計算後返回結果 */
private double cal(double n1, double n2, int c) { // n1,n2為運算數,c為運算類型
switch (c) {
case 0:
return n1 + n2;
case 1:
return n1 - n2;
case 2:
return n2 - n1;
case 3:
return n1 * n2;
case 4:
if (n2 == 0)
return 9999; // 使計算結果必不為24
else
return n1 / n2;
default:
if (n1 == 0)
return 9999; // 同上
else
return n2 / n1;
}
}

/** calString(),輸出表達式 */
private String calString(double[] n, int t1, int c1, int t2, int c2, int c3) {
String[] nString = new String[4];
switch (t1) {
case 0:
nString[0] = calString2("" + (int) n[0], "" + (int) n[1], c1);
nString[1] = "" + (int) n[2];
nString[2] = "" + (int) n[3];
break;
case 1:
nString[0] = calString2("" + (int) n[0], "" + (int) n[2], c1);
nString[1] = "" + (int) n[1];
nString[2] = "" + (int) n[3];
break;
case 2:
nString[0] = calString2("" + (int) n[0], "" + (int) n[3], c1);
nString[1] = "" + (int) n[1];
nString[2] = "" + (int) n[2];
break;
case 3:
nString[0] = calString2("" + (int) n[1], "" + (int) n[2], c1);
nString[1] = "" + (int) n[0];
nString[2] = "" + (int) n[3];
break;
case 4:
nString[0] = calString2("" + (int) n[1], "" + (int) n[3], c1);
nString[1] = "" + (int) n[0];
nString[2] = "" + (int) n[2];
break;
default:
nString[0] = calString2("" + (int) n[2], "" + (int) n[3], c1);
nString[1] = "" + (int) n[0];
nString[2] = "" + (int) n[1];
}
if ((c2 / 3 > c1 / 3 && (t2 != 2 || c2 / 3 == c3 / 3))
|| ((c3 / 3 > c1 / 3 + c2 / 3) && t2 == 2)
|| (c3 == 1 && c1 / 3 == 0)) // 特定情況下加上一個括弧*****************************
nString[0] = '(' + nString[0] + ')';
switch (t2) {
case 0:
nString[0] = calString2(nString[0], "" + nString[1], c2);
nString[1] = nString[2];
break;
case 1:
nString[0] = calString2(nString[0], nString[2], c2);
break;
default:
nString[3] = nString[0];
nString[0] = calString2(nString[1], nString[2], c2);
nString[1] = nString[3];
}
if (c3 / 3 > c2 / 3 || (c3 == 2 && nString[0].indexOf('+') >= 0)) // 特定情況下加上一個括弧*****************************
nString[0] = '(' + nString[0] + ')';
return calString2(nString[0], nString[1], c3);
}

/** calString(),根據符號輸出一部運算表達式 */
private String calString2(String n1, String n2, int c) {
switch (c) {
case 0:
return n1 + '+' + n2;
case 1:
return n1 + '-' + n2;
case 2:
return n2 + '-' + n1;
case 3:
return n1 + '*' + n2;
case 4:
return n1 + '/' + n2;
default:
return n2 + '/' + n1;
}
}

}