-2

我刚刚开始在 Hackerrank 中解决问题,我的代码甚至没有通过示例测试用例,它得到“运行时错误”。据说,它等待标准输入上的换行符,这就是为什么不输出结果。

例如,对于以下输入情况:1 1 1 1 1 1 1 1 1 1 1 ........

它将等到光标移动到下一行。

这是问题的链接:https ://www.hackerrank.com/challenges/find-point

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();
 }
}
4

1 回答 1

0

改变

public class FindPoint

class Solution

并确保从语言列表中选择 Java。

于 2014-06-29T19:56:32.130 回答