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


C# Options.parse方法代码示例

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


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

示例1: Main

    static void Main(String[] args)
    {
        Options options = new Options();
        if (!options.parse(args)) {
            //return;
        }

        Scanner scanner = new Scanner();

        // Take all the parameters from the input
        double a, b;
        int N;
        int fx;
        int _realN;

        // ------ lower limit input -----
        Console.Write("Ingrese a: ");
        if (options.isASet) {
            a = options.a;
            Console.WriteLine(a);
        } else {
            a = scanner.nextDouble();
        }

        // ------ upper limit input -----
        Console.Write("Ingrese b: ");
        if (options.isBSet) {
            b = options.b;
            Console.WriteLine(b);
        } else {
            b = scanner.nextDouble();
        }

        // ------ number of partitions input -----
        Console.Write("Ingrese N: ");
        if (options.isNumPartitionsSet) {
            N = options.numPartitions;
            Console.WriteLine(N);
        } else {
            N = scanner.nextInt();
        }
        _realN = 3 * N;

        Console.WriteLine("Seleccione la funcion a integrar (1 - {0}):", functions.Length);
        for (int i = 0; i < functions.Length; i++) {
            Console.WriteLine("   opcion #{0}: {1}", i, functions[i].GetName());
        }

        // ------ function index input ------
        if (options.isFxSet) {
            Console.Write(" ingrese la opcion: ");
            fx = options.fx;
            Console.WriteLine(fx);
        } else {
            do {
                Console.Write(" ingrese la opcion: ");
                fx = scanner.nextInt();
            } while (fx < 0 || fx >= functions.Length);
        }

        Console.WriteLine();

        // ----- begin to calculate the final results -----

        double h = (b - a) / _realN;

        Console.WriteLine("Resultado Integracion:");
        Console.WriteLine("==========================");
        Console.WriteLine();

        Console.WriteLine("Funcion a integrar      : {0}", functions[fx].GetName());
        Console.WriteLine("Numero de particiones   : 3 * (N={0}) = {1}", N, _realN);
        Console.WriteLine("Limite inferior         : {0}", a);
        Console.WriteLine("Limite superior         : {0}", b);
        Console.WriteLine("Paso (h = (b-a)/N)      : {0}", h);

        // ----- solve and print the final result -----------

        MainSolver solver = new MainSolver(a, b, h, _realN, functions[fx]);
        double result = solver.ExecuteThreads();
        Console.WriteLine("Resultado de integracion: {0}", result);
    }
开发者ID:rtapiapincheira,项目名称:sistemas-operativos-lab2,代码行数:82,代码来源:MainClass.cs


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