slope lines by Paul

using System;\x0d
using System.Collections;\x0d
class P {\x0d
    static void Main() {\x0d
        string s, ch, line = "", spaces = "";\x0d
        string[] lines = new string[10];\x0d
        int len = 0, i = 0, j=0, k=0, count = 1, max = 0;\x0d
        bool test = false;\x0d
        int ti = 0;\x0d
        string[,] t = {\x0d
            {\x0d
                "Today is the day.",\x0d
                null,\x0d
                null,\x0d
                null,\x0d
                null,\x0d
                null,\x0d
                null,\x0d
                null,\x0d
                null\x0d
            },\x0d
            {\x0d
                "Idle hands are the devil's workshop.",\x0d
                "An eye for an eye, and a tooth for a tooth.",\x0d
                "Call a spade a spade.",\x0d
                "Failure teaches success.",\x0d
                null,\x0d
                null,\x0d
                null,\x0d
                null,\x0d
                null\x0d
            },\x0d
            {\x0d
                "A wonder lasts but nine days.",\x0d
                "Better be first in the village than second at Rome.",\x0d
                "Catch your bear before you sell its skin.",\x0d
                "Divide and rule.",\x0d
                "Everybody's business is nobody's business.",\x0d
                "Fair is foul, and foul is fair.",\x0d
                "He who chooses takes the worst.",\x0d
                "It will be all the same a hundred years hence.",\x0d
                null\x0d
            }\x0d
                      };\x0d
        if (test) {\x0d
            s = t[ti, len];\x0d
        } else {\x0d
            s = Console.ReadLine();\x0d
        }\x0d
        do {\x0d
            lines[len] = s;\x0d
            count = lines[len].Length;\x0d
            max = count > max ? count + len : max + 1;\x0d
            len++;\x0d
            if (test) {\x0d
                s = t[ti, len];\x0d
            } else {\x0d
                s = Console.ReadLine();\x0d
            }\x0d
        } while (s != null);\x0d
        for (i = max; i >=0; i--) {\x0d
            line = "";\x0d
            spaces = "";\x0d
            for (k = 0; k < i - len; k++) {\x0d
                spaces += "  ";\x0d
            }\x0d
            for (j = 0; j < len; j++) {\x0d
                count = i - (len - j);\x0d
                if (count >= 0) {\x0d
                    if (count < lines[j].Length) {\x0d
                        ch = lines[j].Substring(count, 1);\x0d
                        line += spaces + lines[j].Substring(count, 1);\x0d
                        spaces = "   ";\x0d
                    } else {\x0d
                        spaces += "    ";\x0d
                    }\x0d
                }\x0d
                else {\x0d
                    spaces += "  ";\x0d
                }\x0d
            }\x0d
            if (i != max || line.Length != 0) {\x0d
                Console.WriteLine(line);\x0d
            }\x0d
        }\x0d
    }\x0d
}\x0d

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page