//很简单
import java.util.Scanner;
public class TestInput {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("输入5个数用空格隔开:");
String input = scanner.nextLine();
System.out.println(input);
String[] nums = input.split(" ");
System.out.println(nums.length);
for (String s : nums) {
if (Integer.parseInt(s) > 0) {
System.out.println(s + " 为正");
} else if (Integer.parseInt(s) < 0) {
System.out.println(s + " 为负");
} else {
}
}
}
}
Scanner scanner=new Scanner(System.in);
int i=0;
System.out.println("请输入5个数字")
for(i;i<5;i++)
{
i=scanner.nextInt();
if(i<0)
{
System.out.println(i+"为负数")
}
else if(i==0)
{
System.out.println(i+"为0")
}
else
{
System.out.println(i+"为正数")
}
}
是不是要这样的结果啊?