这是我想要实现的目标。
输入:
5
1 2 3 -4 -5 -6 -7 -8 -9
预期输出:
The list is 1 2 3 -4 -5.
There are 3 positive numbers and 2 negative numbers.
示例代码:
String[] s = sc.nextLine().split(" ");
for(int i=0;i<n;i++)
{
...
}
System.out.printf("The list is %s.\nThere are %d positive numbers and %d negative numbers",(s.toString().substring(0,n)),pos,neg);
sc.close();
现在输出:
The list is [Ljav.
There are 3 positive numbers and 2 negative numbers.
尝试应用Integer.parseint(s.toString().substring(0,n)),%d但也得到了与上面相同的输出。如何纠正这个?
料青山看我应如是
一只斗牛犬
守候你守候我
相关分类