本文整理汇总了C#中IScanner.NextInt方法的典型用法代码示例。如果您正苦于以下问题:C# IScanner.NextInt方法的具体用法?C# IScanner.NextInt怎么用?C# IScanner.NextInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScanner
的用法示例。
在下文中一共展示了IScanner.NextInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Solve
private static string Solve(IScanner scanner)
{
int numberOfPhoneNumbers = scanner.NextInt();
Program.PhoneNode phoneBook = new Program.PhoneNode(String.Empty, false);
string answer = null;
for (int j = 0; j < numberOfPhoneNumbers; j++)
{
var no = scanner.Next();
Debug.WriteLine("Processing: " + no);
if (answer != null)
continue;
var current = phoneBook;
for (int index = 0; index < no.Length; index++)
{
var digit = no[index] - '0';
if (current.Nodes[digit] == null)
current.Nodes[digit] = new PhoneNode(current.Id + digit, index == no.Length - 1);
else if (index == no.Length - 1 || current.Nodes[digit].IsStop)
{
// if this is my last digit and number already used - 'NO'
// if some other number finished here - 'NO'
// number already exists
answer = "NO";
break;
}
current = current.Nodes[digit];
}
}
return answer ?? "YES";
}