static void Main(string[] args) { mathvoid op = new mathvoid(); string Z = ""; do { int z = new Random().Next(4) + 1; switch (z) { case 1: op.mathjia(); continue; case 2: op.mathjian(); continue; case 3: op.mathcheng(); continue; case 4: op.mathchu(); continue; default: Console.WriteLine("输入无效!"); continue; } break; }while (true); }
static void Main(string[] args) { mathvoid op = new mathvoid(); string Z = ""; do { Console.WriteLine("-------------------------------四则运算-------------------------"); Console.WriteLine(""); Console.WriteLine("请选择您使用的运算方法:1.加法 2.减法 3.乘法 4.除法 5.退出!"); Z = Console.ReadLine(); switch (Z) { case "1": op.mathjia(); continue; case "2": op.mathjian(); continue; case "3": op.mathcheng(); continue; case "4": op.mathchu(); continue; case "5": op.result(); break; default: Console.WriteLine("输入无效!"); continue; } break; }while (true); }
static void Main(string[] args) { mathvoid op = new mathvoid(); int a = 0; int n = 0; int i = 0; string Z = ""; Random r = new Random(); a = r.Next(0, 4); Console.WriteLine(""); Console.WriteLine("请输入出题数目:"); n = int.Parse(Console.ReadLine()); for (i = 0; i < n; i++) { Z = a.ToString(); switch (Z) { case "1": op.mathjia(); continue; case "2": op.mathjian(); continue; case "3": op.mathcheng(); continue; case "4": op.mathchu(); continue; } } Console.WriteLine("总共答对" + op.getright() + "道题!答错" + op.getwrongt() + "道题!"); }