Пример #1
0
        static string MakeText(int number, BooleanFunction f, int varCount, bool withAnswer)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Case \\#" + number);

            var operations = f.Subtree.OfType<Operation>().Reverse().ToArray();
            for (int i = 0; i < operations.Length; i++)
                operations[i].Letter = ((char)('A' + i)).ToString();

            string arrayTail = "";
            for (int i = 0; i < varCount; i++)
                arrayTail += "c";
            arrayTail += "||";
            for (int i = 0; i < operations.Length; i++)
            {
                if (i != 0 && i % 3 == 0)
                    arrayTail += "|";
                arrayTail += "c";
            }
            arrayTail += "c";

            builder.Append("$$\n"+f.Tex() + "$$\n\n");

            builder.Append("\\begin{tabular}{" + arrayTail + "}\n");
            for (int i = 0; i < varCount; i++)
                builder.Append(Variable.Names[i] + "&");
            foreach (var e in operations)
                builder.Append("\\rotatebox{90}{$" + e.Letter + "=" + e.LetterTex() + "$}&");
            builder.Append("\\\\\n\\hline\n");

            var values = new bool[varCount];
            do
            {
                for (int i = 0; i < varCount; i++)
                    builder.Append(Cell(values[i]));
                foreach (var e in f.Subtree.OfType<Operation>().Reverse())
                    builder.Append(withAnswer?Cell(e.Evaluate(values)):"&");
                builder.Append("\\\\\n\\hline\n");
            } while (Next(values));
            builder.Append("\\end{tabular}\n\n");
            builder.Append("\\pagebreak\n\n");
            return builder.ToString();
        }
Пример #2
0
 static BooleanFunction CreateNegation(BooleanFunction f)
 {
     if (rnd.Next(100) < negationProbability)
         return new Negation { InnerFunction = f };
     return f;
 }