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


C# Scanner.Next方法代码示例

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


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

示例1: Pushbacktest

		[Test] public void Pushbacktest()
		{
			Scanner scanner = new Scanner("100");
			Token t = scanner.Next();
			scanner.Pushback(t);
			Token t2 = scanner.Next();
			Assert.AreSame(t, t2); 
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:8,代码来源:ScannerTests.cs

示例2: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        string[] a = new string[3];
        for (int i = 0; i < 3; i++)
            a[i] = input.Next();

        int max = 0, min = 0, max_c = 1;
        for (int i = 1; i < 3; i++) {
            if (a[i].Length > a[max].Length ||
                (a[i].Length == a[max].Length && a[i].CompareTo(a[max]) > 0)) {
                max = i;
                max_c = 1;
            } else if (a[i] == a[max]) {
                max_c++;
            } else {
                min = i;
            }
        }

        string[] names = new string[] { "Mary", "Klaus", "Peter" };

        if (max_c == 1)
            Console.WriteLine(names[max]);
        else if (max_c == 2)
            Console.WriteLine(names[min]);
        else
            Console.WriteLine("Draw");
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:30,代码来源:B117.cs

示例3: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        N = input.NextInt();
        map = new char[N + 2, N + 2];
        mm = new char[N + 2, N + 2];

        for (int i = 0; i < N + 2; i++)
            for (int j = 0; j < N + 2; j++)
                map[i, j] = '#';

        for (int i = 1; i <= N; i++) {
            string s = input.Next();
            for (int j = 1; j <= N; j++)
                map[i, j] = s[j-1];
        }

        next = new char[256];
        dx = new int[256];
        dy = new int[256];
        for (int i = 0; i < 4; i++) {
            next["|/-\\"[i]] = "/-\\|"[i];
            dy["|/-\\"[i]] = "2212"[i] - '1';
            dx["|/-\\"[i]] = "1022"[i] - '1';
        }

        int best = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                best = Math.Max(best, bestAt(i, j));
            }
        }
        Console.WriteLine(best);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:35,代码来源:198.cs

示例4: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        string s = input.Next();
        int N = s.Length;

        int[, ,] dp = new int[N, N, 3];
        for (int len = 1; len <= N; len++) {
            for (int a = 0; a <= N-len; a++) {
                int b = a + len - 1;
                for (int side = 0; side < 3; side++) {
                    int res = b - a + 1;
                    for (int c = a; c <= b; c++) {
                        int cost = 1;
                        if (side == 1 && a > 0 && s[a - 1] == s[c]) cost = 0;
                        if (side == 2 && b + 1 < N && s[b + 1] == s[c]) cost = 0;

                        if (a < c) cost += dp[a, c - 1, 2];
                        if (c < b) cost += dp[c + 1, b, 1];

                        if (cost < res)
                            res = cost;
                    }
                    dp[a, b, side] = res;
                }
            }
        }

        Console.WriteLine(dp[0, N - 1, 0]);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:31,代码来源:216.cs

示例5: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        int N = input.NextInt();
        string s = input.Next();

        Console.WriteLine(Check(s) ? "Yes" : "No");
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:9,代码来源:A155.cs

示例6: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        string a = input.Next().Trim('0');
        string b = input.Next().Trim('0');

        string c = "";
        int carry = 0;
        for (int i = 0; i < a.Length || i < b.Length || carry != 0; i++) {
            if (i < a.Length) carry += a[i] - '0';
            if (i < b.Length) carry += b[i] - '0';
            c += (char)('0' + (carry % 10));
            carry /= 10;
        }
        c = c.Trim('0');

        Console.WriteLine(c);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:19,代码来源:A179.cs

示例7: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        int[,] source = new int[4, 4];
        int[,] grid = new int[4, 4];

        for (int i = 0; i < 4; i++) {
            string s = input.Next();
            for (int j = 0; j < 4; j++)
                source[i, j] = (s[j] == 'w' ? 0 : 1);
        }

        int best = 999;

        for (int goal = 0; goal < 2; goal++) {
            for (int mask = 0; mask < 16; mask++) {
                for (int i = 0; i < 4; i++)
                    for (int j = 0; j < 4; j++)
                        grid[i, j] = source[i, j];

                int res = 0;

                for (int i = 0; i < 4; i++) {
                    if ((mask & (1 << i)) != 0) {
                        res++;
                        flip(grid, 0, i);
                    }
                }

                for (int row = 0; row < 4; row++) {
                    for (int col = 0; col < 4; col++) {
                        if (grid[row, col] != goal) {
                            if (row == 3)
                                res = 999;
                            else {
                                flip(grid, row + 1, col);
                                res++;
                            }
                        }
                    }
                }

                if (res < best)
                    best = res;
            }
        }

        if (best > 16)
            Console.WriteLine("Impossible");
        else
            Console.WriteLine(best);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:53,代码来源:A163.cs

示例8: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        string N = input.Next();
        int K = input.NextInt();

        int res = 0;
        foreach (char ch in N)
            res = (res * 10 + (ch - '0')) % K;

        Console.WriteLine(res);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:13,代码来源:A129.cs

示例9: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        while (input.HasNext())
        {
            int N = input.NextInt();
            if (N == 0) break;

            string moves = input.Next();
            solve(moves);
        }
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:13,代码来源:183.cs

示例10: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        int[] a = new int[3];
        for (int i = 0; i < 3; i++)
            a[i] = input.NextInt();
        Array.Sort(a);

        string s = input.Next();
        for (int i = 0; i < 3; i++)
            Console.Write(i < 2 ? "{0} " : "{0}\n", a[s[i]-'A']);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:13,代码来源:212.cs

示例11: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        int N = input.NextInt();

        long[] v = new long[N];
        for (int i = 0; i < N; i++)
            v[i] = long.Parse(input.Next());
        Array.Sort(v);

        foreach (long i in v)
            Console.WriteLine(i);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:14,代码来源:A140.cs

示例12: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        int N = input.NextInt();
        int A = 0;

        for (int i = 0; i < N; i++) {
            string op = input.Next();
            string xs = input.Next();
            string ys = input.Next();

            int x = xs == "A" ? A : int.Parse(xs);
            int y = ys == "A" ? A : int.Parse(ys);

            if (op == "MUL")
                A = x * y;
            else
                A = x + y;
        }

        Console.WriteLine(A);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:23,代码来源:201.cs

示例13: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        char[] x = input.Next().ToCharArray();
        int i;
        for (i = 1; i < x.Length; i++) {
            x[i] = (char)('0' + ((x[i] - '0') ^ (x[i - 1] - '0')));
        }

        for (i = 0; i < x.Length - 1 && x[i] == '0'; i++);

        Console.WriteLine(new string(x, i, x.Length - i));
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:14,代码来源:A183.cs

示例14: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        string s = input.Next();

        string res = "";
        for (int i = s.Length - 1; i >= 0; i--) {
            if (s[i] == '_')
                res += ' ';
            else
                res += s[i];
        }

        Console.WriteLine(res);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:16,代码来源:B120.cs

示例15: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        N = input.NextInt();
        M = input.NextInt();
        map = new char[N][];
        for (int i = 0; i < N; i++)
            map[i] = input.Next().ToCharArray();

        int res = 0;
        for (int i = 0; i < N; i++)
            for (int j = 0; j < M; j++)
                if (map[i][j] == '#') {
                    res++;
                    dfs(i, j);
                }
        Console.WriteLine(res);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:19,代码来源:A158.cs


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