使用扫描仪处理线路终结器

时间:2018-11-09 10:16:04

标签: java

给出代码:

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s1 = sc.nextLine();
String s2 = sc.nextLine();

输入:

2
heads are better than
1 head

输出将是:

n="2"
s1=""
s2="heads are better than"

我的问题是如何使所需的输出为:

n="2"
s1="heads are better than"
s2="1 head"

0 个答案:

没有答案