-1
我想首先采取整数N后跟N行,其中每行有两个坐标x和y。 (以空格分隔)。我尝试过,但它给NullPointerException
。输入阅读输入分隔空间
class solution{
class Point{
int x;
int y;
}
public static void main(String[] args) throws IOException {
int N;
Scanner in = new Scanner(System.in);
BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
N=Integer.parseInt(in.next());
Point[] P = new Point[N];
for(i=0;i<N;i++){
String[] s1 = inp.readLine().split(" ");
P[i].x=Integer.parseInt(s1[0]);
P[i].y=Integer.parseInt(s1[1]);
}
}
例如:
4
2 4
5 7
8 9
1 0
为什么你使用'Scanner'和'BufferedReader'呢?使用其中任何一个。 –
好的,你能告诉我们你在哪一行得到NullPointerException? – Ajeesh
@RohitJain只能去练习..并且请不要做任何作业 – user119249