当前位置: 首页>>代码示例>>C#>>正文


C# Solution.solve方法代码示例

本文整理汇总了C#中Solution.solve方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.solve方法的具体用法?C# Solution.solve怎么用?C# Solution.solve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solution的用法示例。


在下文中一共展示了Solution.solve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    public static void Main(string[] args)
    {
        Solution solution = new Solution();
        using (System.IO.TextReader input =
                CaideConstants.InputFile == null ? System.Console.In :
                        new System.IO.StreamReader(CaideConstants.InputFile))
        using (System.IO.TextWriter output =
                CaideConstants.OutputFile == null ? System.Console.Out:
                        new System.IO.StreamWriter(CaideConstants.OutputFile))

            solution.solve(input, output);
    }
开发者ID:saint1729,项目名称:caide,代码行数:12,代码来源:submission.cs

示例2: Main

    public static void Main(string[] args)
    {
        // Read path to caide executable from a file in current directory
        string testDir = ".";
        string caideExeFile = Path.Combine(testDir, "caideExe.txt");
        if (!File.Exists(caideExeFile))
        {
            testDir = Path.Combine(".caideproblem", "test");
            caideExeFile = Path.Combine(testDir, "caideExe.txt");
        }
        if (!File.Exists(caideExeFile))
        {
            throw new InvalidOperationException("Test must be run from either problem directory or .caideproblem/test subdirectory");
        }
        string caideExe = File.ReadAllText(caideExeFile).Trim();

        // Prepare the list of test cases in correct order; add recently created test cases too.
        Process updateTestsProcess = Run(caideExe, "update_tests");
        updateTestsProcess.WaitForExit();
        if (updateTestsProcess.ExitCode != 0)
        {
            Console.Error.WriteLine("caide update_tests returned non-zero error code " + updateTestsProcess.ExitCode);
        }

        // Process each test case described in a file in current directory
        foreach (string line in File.ReadAllLines(Path.Combine(testDir, "testList.txt")))
        {
            string[] words = line.Split(' ');
            string testName = words[0], testState = words[1];
            if (testState == "Skip")
            {
                Console.Error.WriteLine("Skipping test " + testName);
                // mark test as skipped
                File.WriteAllText(Path.Combine(testDir, testName + ".skipped"), "");
            }
            else if (testState == "Run")
            {
                Console.Error.WriteLine("Running test " + testName);
                TextWriter output = new StringWriter();

                using (TextReader input = new StreamReader(Path.Combine(testDir, testName + ".in")))
                {
                    try
                    {
                        Solution solution = new Solution();
                        solution.solve(input, output);
                    }
                    catch
                    {
                        Console.Error.WriteLine("Test " + testName + " threw an exception");
                        // mark test as failed
                        File.WriteAllText(Path.Combine(testDir, testName + ".failed"), "");
                    }
                }

                // save program output
                string result = output.ToString();
                File.WriteAllText(Path.Combine(testDir, testName + ".out"), result);

                // optional: print program output to stderr
                if (result.Length > 100)
                    result = result.Substring(0, 100) + "[...] (output truncated)\n";
                Console.Error.WriteLine(result);
            }
            else
            {
                // internal caide error: unknown test status
                File.WriteAllText(Path.Combine(testDir, testName + ".error"), "");
            }
        }

        // optional: evaluate tests automatically
        Process evalTestsProcess = Run(caideExe, "eval_tests");
        evalTestsProcess.WaitForExit();
        if (evalTestsProcess.ExitCode != 0)
        {
            Console.Error.WriteLine("Tests failed (exit code: " + evalTestsProcess.ExitCode + " )");
            Environment.Exit(evalTestsProcess.ExitCode);
        }
    }
开发者ID:saint1729,项目名称:caide,代码行数:80,代码来源:test_template.cs

示例3: Main

 public static void Main(string[] args)
 {
     Solution solution = new Solution();
     solution.solve(System.Console.In, System.Console.Out);
 }
开发者ID:saint1729,项目名称:caide,代码行数:5,代码来源:main_template.cs


注:本文中的Solution.solve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。