短短幾周,基本上已經快學完了C#,當然了,學了之後就要練習,這是最基本的學習方式。是以呢?動動你的手指一起來學習吧!
(
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//int i = Convert.ToInt32(Console.ReadLine());
// Console.WriteLine("{0}",i);
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// 一、實作簡單的電腦,控制台模式:
//實作兩個數的四則運算
//對除法和取餘進行除零判斷.
while(true){
int m, n;
Console.WriteLine("+,-,/,%分别用0,1,2,3來替代");
Console.Write("請輸入第一個數m:");
m = Convert.ToInt32(Console.ReadLine());
Console.Write("請輸入第二個數n:");
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("請輸入你想要進行的運算:+,-,/,%:");
int singal;
singal = Convert.ToInt32(Console.ReadLine());
switch (singal)
{
case 0:
Console.WriteLine("m+n={0}", (m + n));
break;
case 1:
Console.WriteLine("m-n={0}", (m - n));
break;
case 2:
if (n == 0)
{
Console.WriteLine("error");
}
else
{
Console.WriteLine("m/n={0}", m / n);
}
break;
case 3:
if (n == 0)
{
Console.WriteLine("error");
}
else
{
Console.WriteLine("m%n={0}", m % n);
}
break;
default:
Console.WriteLine("error");
break;
}
Console.WriteLine("================================");
}
}
}
}
累嗎?讓小妲己來給你捶捶~~~~~~~~~~~