program.cs

来自「这是自己写的很简单的程序代码,很简单!!希望你能看上」· CS 代码 · 共 60 行

CS
60
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace calculate
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            double b,c;
            Console.WriteLine("请选择要进行的计算:1加2减3乘4除");
            try
            {
                a = Convert.ToInt32(Console.ReadLine());
                switch (a)
                {
                    case 1:
                        Console.WriteLine("第一个操作数:");
                        b = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("第二个操作数:");
                        c = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("{0}+{1}={2}", b, c, b + c);
                        break;
                    case 2:
                        Console.WriteLine("第一个操作数:");
                        b = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("第二个操作数:");
                        c = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("{0}-{1}={2}", b, c, b - c);
                        break;
                    case 3:
                        Console.WriteLine("第一个操作数:");
                        b = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("第二个操作数:");
                        c = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("{0}*{1}={2}", b, c, b * c);
                        break;
                    case 4:
                        Console.WriteLine("第一个操作数:");
                        b = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("第二个操作数:");
                        c = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("{0}/{1}={2}", b, c, b / c);
                        break;
                    default:
                        Console.WriteLine("输入错误!");
                        break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?