Пример #1
0
        public string cv(string equation)
        {
            jisuan x = new jisuan();
            int    u;//判断是否分母为0
            int    nm;
            int    weizhi = 0;
            string last   = null;       //最终产生的结果
            string rt     = null;       //计算结果字符串

            u = equation.IndexOf("\0"); //不能出现分母为0的情况
            if (u == -1)
            {
                rt     = x.result(equation);
                weizhi = rt.IndexOf(".");//不能出现结果为小数的情况
                if (weizhi == -1)
                {
                    last = equation + "=" + rt;
                    return(last);
                }
                else
                {
                    return(" ");
                }
            }
            else
            {
                return(" ");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            string bg       = null;
            string h        = null;
            string equation = null;                          //产生的式子
            int    nm       = int.Parse(Console.ReadLine()); //输入生成的算式的个数
            fun    f        = new fun();                     //Console.WriteLine(nm.ToString());

            for (int i = 0; i < nm; i++)
            {
                jisuan x = new jisuan();
                equation = x.setequal();
                bg       = f.cv(equation);
                if (bg != " ")
                {
                    h = h + bg + "\r\n";
                }
                else
                {
                    i--;
                    continue;
                }
            }
            Console.WriteLine(h);
            System.IO.File.WriteAllText("E:/subject.txt", h, Encoding.Default);
            Console.ReadKey();
        }