- using static System.Formats.Asn1.AsnWriter;
- double num1, num2;
- string oper;
- re:
- System.Console.Write("請輸入第一個數:");
- num1 = System.Convert.ToDouble(System.Console.ReadLine());
- System.Console.Write("請輸入要做的運算(+、-、*、/) : ");
- oper= System.Console.ReadLine();
- System.Console.Write("請輸入第二個數:");
- num2 = System.Convert.ToDouble(System.Console.ReadLine());
- if (oper == "+")
- System.Console.WriteLine(num1 + " + " + num2 + " = " + (num1 + num2));
- else if (oper == "-")
- System.Console.WriteLine(num1 + " - " + num2 + " = " + (num1 - num2));
- else if (oper == "*")
- System.Console.WriteLine(num1 + " * " + num2 + " = " + (num1 * num2));
- else if (oper == "/")
- System.Console.WriteLine(num1 + " / " + num2 + " = " + (num1 / num2));
- else
- System.Console.WriteLine("不合法的運算符號");
- goto re;
複製代碼 |