using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tmd
{
    class Program
    {
       private static int sun;
        static void Main(string[] args)
        {
            Console.Write("请输入你要进行的运算(+):");
            string f = Console.ReadLine();
            Console.Write("请输入第一个数:");
            int a = int.Parse(Console.ReadLine());
            Console.Write("请输入第二个数:");
            int b = int.Parse(Console.ReadLine());
            Console.Write("请输入答案:");
            int y = int.Parse(Console.ReadLine());
            calcula(f,a,b);
            if (y == sun)
            {
                Console.WriteLine("恭喜你答对了!");
            }
            else
            {
                Console.WriteLine("很遗憾你答错了!");
                Console.WriteLine(sun);
            }

            Console.Read();
            
            
        }
        private static int calcula(string operato, int a, int b)
        {
           
            switch (operato)
            {
                case "+":
                    sun=a+b;
                    break;
                case "-":
                    sun = a - b;
                    break;
                case "*":
                    sun = a * b;
                    break;
                case "/":
                    sun = a / b;
                    break;

            }
            return sun;
 
        }
    }
}

总结:

用控制台来写的,不知道这样写行不行!

谢谢老师@沉默的代码

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2021-06-16
猜你喜欢
  • 2021-09-09
  • 2022-12-23
  • 2021-09-27
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案