java笔试的要求的输入该怎么写

如要求输入以下数据
1,2
3,3
...
或者要求以空格分隔每行的输入的数据,如:
1 2
3 3
...

public class demo1 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int count=Integer.parseInt(in.nextLine());
        int[][] num=new int[count][2];
        for(int i=0;i<count;i++){
            String[] ss=in.nextLine().trim().split(",");
            num[i][0]=Integer.parseInt(ss[0]);
            num[i][1]=Integer.parseInt(ss[1]);
        }
    }
}
posted @ 2021-04-01 15:06  Moment_Lss  阅读(115)  评论(0编辑  收藏  举报