本文整理汇总了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);
}
示例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");
}
示例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);
}
示例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]);
}
示例5: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
string s = input.Next();
Console.WriteLine(Check(s) ? "Yes" : "No");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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']);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}