回覆列表
  • 1 # 滴逃逃

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    namespace ConsoleApplication3

    {

    class Program

    {

    static void Main(string[] args)

    {

    Console.WriteLine("第一個數:");

    int a = Convert.ToInt32(Console.ReadLine());

    Console.WriteLine("輸入運算子(+—*/)");

    // c=Console.ReadLine();

    char str=Convert.ToChar(Console.ReadLine());

    Console.WriteLine("第er個數:");

    int b = Int32.Parse(Console.ReadLine());

    //int c = a + b;

    //Console.WriteLine("兩個數和為:{0}",c);

    switch (str) {

    case "+":

    Console.WriteLine("兩個數和為:{0}", a+b);

    break;

    case "-":

    Console.WriteLine("兩個數差為:{0}", a-b);

    break;

    case "*":

    Console.WriteLine("兩個數積為:{0}", a*b);

    break;

    case "/":

    Console.WriteLine("兩個數商為:{0}", a/b);

    break;

    case "%":

    Console.WriteLine("兩個數餘數為:{0}", a % b);

    break;

    default:

    Console.WriteLine("輸入正確的運算子!!");

    break;

    }

    }

    }

    }

  • 中秋節和大豐收的關聯?
  • 愛情、事業、健康和金錢哪個更重要?你是怎樣排序的?