我想实现,根据第一个参数指定的行数,在输入这么多行后,输出结果,比如,输入
2(注释:行数)
1 23 6
3 5
那么在输入5回车后,就输出结果为
1 23 6
3 5我写了一个,有问题,望指教public class TestScanner {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int count = scanner.nextInt();
while(count-- != 0){
System.out.println(scanner.nextLine());
}
}
}
2(注释:行数)
1 23 6
3 5
那么在输入5回车后,就输出结果为
1 23 6
3 5我写了一个,有问题,望指教public class TestScanner {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int count = scanner.nextInt();
while(count-- != 0){
System.out.println(scanner.nextLine());
}
}
}
import java.util.Scanner;public class Test{
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int count = Integer.parseInt(scanner.nextLine());
while(count-- != 0){
System.out.println(scanner.nextLine());
}
}
}
import java.util.Scanner;public class Test{
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int count = Integer.parseInt(scanner.nextLine());
String[] str = new String[count];
for(int i = 0; i < count; i++)
{
str[i] = scanner.nextLine();
}
for(int i = 0; i < count; i++)
{
System.out.println(str[i]);
}
}
}