Java System.in停止等待下一行并打印输出
我刚刚开始解决Hackerrank中的问题,我的代码甚至没有通过示例测试用例,它得到了“运行时错误”。据推测,它等待stdin上的新行字符,这就是为什么不输出结果 例如,对于以下输入情况: 1. 1.1.1 它将等待光标移到下一行 这就是问题的症结所在:Java System.in停止等待下一行并打印输出,java,runtime-error,system.in,Java,Runtime Error,System.in,我刚刚开始解决Hackerrank中的问题,我的代码甚至没有通过示例测试用例,它得到了“运行时错误”。据推测,它等待stdin上的新行字符,这就是为什么不输出结果 例如,对于以下输入情况: 1. 1.1.1 它将等待光标移到下一行 这就是问题的症结所在: import java.util.Scanner; 公共类查找点{ 公共静态void main(字符串[]args){ 扫描仪输入=新扫描仪(System.in); int testCases=input.nextInt(); int[]点=新
import java.util.Scanner;
公共类查找点{
公共静态void main(字符串[]args){
扫描仪输入=新扫描仪(System.in);
int testCases=input.nextInt();
int[]点=新的int[4*测试用例];
int x=0;
int y=0;
int i=0;
而(i
更改
公共类FindPoint
到
类解决方案
并确保从语言列表中选择Java。您是否收到除“运行时错误”以外的更具体的错误?
import java.util.Scanner;
public class FindPoint {
public static void main(String[] args){
Scanner input =new Scanner(System.in);
int testCases = input.nextInt();
int [] points = new int [4 * testCases];
int x = 0;
int y = 0;
int i = 0;
while(i < testCases){
points[i] = input.nextInt();
points[i + 1] = input.nextInt();
points[i + 2] = input.nextInt();
points[i + 3] = input.nextInt();
x = 2*points[2 + i] - points[0 + i];
y = 2*points[3 + i] - points[1 + i];
System.out.println(x + " " + y);
i++;
}
input.close();
}
}