1 static void Main(string[] args) 2 { 3 4 //两个数的和 或者差 5 Console.WriteLine("请输入第一个操作数:"); 6 int num1 = Convert.ToInt32(Console.ReadLine()); 7 Console.WriteLine("请输入第一个操作运算符:"); 8 string oper =Console.ReadLine(); 9 Console.WriteLine("请输入的二个操作数:"); 10 int num3 = Convert.ToInt32(Console.ReadLine()); 11 12 int result = 0; 13 switch(oper){ 14 15 case "+": 16 result = num1 + num3; 17 break; 18 case "-": 19 result = num1 - num3; 20 break; 21 case "/": 22 result = num1 / num3; 23 break; 24 case "*": 25 result = num1 * num3; 26 break; 27 28 29 30 } 31 32 33 Console.WriteLine("结果为:"+result); 34 Console.ReadLine(); 35 } 36 }