//程序中注视的那句话什么意思? cin.skip("\\s\\D"); //这句话是什么意思?import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[]) throws Exception {
Scanner cin=new Scanner(System.in);
int t = cin.nextInt();
for (int i = 0; i < t; i++) {
if (cin.hasNextBigInteger() == false)
cin.skip("\\s\\D"); //这句话是什么意思?
BigInteger a = cin.nextBigInteger();
if (cin.hasNextBigInteger() == false)
cin.skip("\\s\\D");
BigInteger b = cin.nextBigInteger();
a = a.add(b);
System.out.println(a);
}
}
}
此方法调用 skip(pattern) 的行为与调用 skip(Pattern.compile(pattern)) 完全相同。
参数:
pattern - 指定要跳过的模式的字符串
返回:
此扫描器
抛出:
IllegalStateException - 如果此扫描器已关闭有问题多查API
楼主找个API看看,这些都有的。
比如你输入的是"\S\D123",输出就是"123"
在忽略分隔符的情况下跳过与指定模式匹配的输入信息。
Scanner skip(String pattern)
跳过与从指定字符串构造的模式匹配的输入信息。
这句话的意思是在忽略分隔符的情况下跳过空白字符,非数字的输入信息