1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| using System; using System.Reflection; using System.Runtime.InteropServices;
namespace JSQ3._0 { class Program { static void Main(string[] args) { double[] maths = new double[3] { 0, 0, 0 }; A: string userName = Environment.UserName; Console.Title = "欢迎您," + userName; Console.Clear(); Console.WriteLine("欢迎打开TAOG's计算器3.0\n本软件依旧使用C#开发\n按M键进入更新日志\n按非M键开始使用~"); var M = Console.ReadLine(); if (M == "M" ||M == "m") { Readme(); goto A; } C: Console.Clear();
Console.Title = "计算中..."; while (true) { Console.Write("请输入第一个数字:"); try { maths[0] = double.Parse(Console.ReadLine()); } catch (Exception) { Console.WriteLine("请输入正确的内容!!!"); continue; } break; }
while (true) { Console.Write("请输入第二个数字:"); try { maths[1] = double.Parse(Console.ReadLine()); } catch (Exception) { Console.WriteLine("请输入正确的内容!!!"); continue; } break; }
while(true) { B: Console.Write("请输入运算符(加减乘除或+-*/):"); string fu = Console.ReadLine(); switch (fu) { case "加": add(maths[0], maths[1], ref maths[2]); break; case "+": add(maths[0], maths[1], ref maths[2]); break; case "减": sub(maths[0], maths[1], ref maths[2]); break; case "-": sub(maths[0], maths[1], ref maths[2]); break; case "乘": mul(maths[0], maths[1], ref maths[2]); break; case "*": mul(maths[0], maths[1], ref maths[2]); break; case "除": div(maths[0], maths[1], ref maths[2]); break; case "/": div(maths[0], maths[1], ref maths[2]); break; default: Console.WriteLine("请输入正确的运算符!!!"); goto B;
} break; } Console.Clear(); Console.WriteLine("运算结果为:" + maths[2] + "\n按下任意键重新开始"); Console.ReadKey(); goto C; } static void Readme() { Console.Clear(); Console.Title = "更新日志"; Console.WriteLine("1.优化了源码结构\n2.现在可以进行小数运算了\n按下任意键返回上一个页面"); Console.ReadKey(); return; }
static void add(double a , double b , ref double c) { c = a + b; } static void sub(double a, double b, ref double c) { c = a - b; } static void mul(double a, double b, ref double c) { c = a * b; } static void div(double a, double b, ref double c) { c = a / b; } } }
|