Console.Title = "加减乘除";
double x, y,z=0;
string m;
int n=0;
Console.WriteLine("第一个数:");
x = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("运算符(默认为加):");
m =Console.ReadLine();
m = (m == "加" || m == "+") ? "加" : (m == "减" || m == "-") ? "减" : (m == "乘" || m == "*"||m=="×") ? "乘" : (m == "除" || m == "/"||m=="÷") ? "除":"加" ;
Console.WriteLine("进行的是" + m + "法运算");
Console.WriteLine("第二个数:");
y = Convert.ToDouble(Console.ReadLine());
switch (m)
{
case "加":
z = x + y;
break;
case "减":
z = x - y;
break;
case "乘":
z = x * y;
break;
case "除":
z = x / y;
break;
default:
z = x + y;
break;
}
Console.WriteLine("运算结果是"+z);
Console.ReadKey();