Scanning for input without storing the values in a variable

后端 未结 2 1540
感情败类
感情败类 2021-01-28 12:01

I\'m declaring a 2d Array with 100 rows and columns. Im trying to get the user to dictate the numbers that go into the array. Im supposed to store the values without storing the

2条回答
  •  失恋的感觉
    2021-01-28 12:22

    Well, first of all, you are dealing with a two dimensional array, so you will need two loops, one for the rows and the other for the colums.

    for(int i=0; i<100; i++)
     {
         for(int j=0;j<100;j++)
            {
                   nums[i][j] = scan.nextInt();
            }
    }
    

    This syntax - int[scan.nextInt()][scan.nextInt()]; is not even legal.

提交回复
热议问题