Read integers separated with whitespace into int[] array

前端 未结 10 1896
陌清茗
陌清茗 2020-12-13 19:13

I read line with

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
reader.readLine();

Example input is

10条回答
  •  抹茶落季
    2020-12-13 19:30

    try

     line = reader.readLine();
     String[] s = line.split(" ");
     ...
    

    you can look to StringTokenizer also, but one of the fastest will be to read bytes and iterate them and convert the ascii (utf8?) coded numbers yourself ;)

提交回复
热议问题