编程题A+B和C,求大神解决我的问题!!!
今天刷编程题遇到一个坎,题目是A+B和C,我用的是Java,自己在IDEA上编译运行没有问题,但是牛客网上它一直无法通过,报空指针异常,我怀疑是我用了字符流造成的,但是不明白为什么,求大神指教
代码附上
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(System.in); int count = sc.nextInt(); String line; int a; int b; int c; boolean[] booleans = new boolean[count]; for (int i = 0; i < count; i++) { line = br.readLine(); a = Integer.valueOf(line.split(" ")[0]); b = Integer.valueOf(line.split(" ")[1]); c = Integer.valueOf(line.split(" ")[2]); booleans[i] = (a + b > c); } for (int i = 0; i < count; i++) { System.out.println("Case #" + (i + 1) + ": " + booleans[i]); } br.close(); } }#笔试题目##Java#