-1
저는 2 차원 배열을 가지고 있습니다. 모든 숫자의 합과 모든 숫자의 합을 대각선으로 찾는 것이 저의 목표입니다.double dimension 입력은 첫 번째 행만 가능합니다
BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
int [][] a=new int [5][5];
int same=0;
int sum=0;
System.out.println("Please enter your numbers");
for(int r=0;r<5;r++)
for(int c=0;r<5;r++)
a[r][c]=Integer.parseInt(kb.readLine());
for(int r=0;r<5;r++)
for(int c=0;r<5;r++)
sum=sum+a[r][c];
for(int r=0;r<5;r++)
for(int c=0;r<5;r++)
if (r==c)
{same=same+a[r][c];}
System.out.println("The sum of the diaganols is "+same+" The sum of everything is "+sum);
2 차원 배열을 열었지 만 프로그램을 시작하면 첫 번째 행에 해당하는 5 개의 숫자 만 입력 할 수 있습니다.
정말 프로그래밍에 익숙하지 않은 분, 어리석은 실수를 저에게 용서해주십시오. 감사합니다.