Home > database >  For where is the great god have a look at the code wrong?
For where is the great god have a look at the code wrong?

Time:10-04

Title description
Enter two positive integers m and n, and then input the m line n column matrix of element values, please calculate the matrix of every element and,

Enter
Two positive integers m and n (1 m or less 10 or less, 1 n 10 or less or less)

O
M n column matrix of all the various elements and

The sample input
3 2
1 4 8 2 5 6

Sample output
5
10
11.

The code below
Import the Java. Util. Random;
import java.util.Scanner;

Public class Main {
Public static void main (String [] args) {
Int [] [] aa={{1, 2, 3}, {4, 7}, {8,9,10}};
System. The out. Println (aa) length);
System. The out. Println (aa [1]. Length);
Int [] [] cc=new int [3] [].
Cc [0]=new int [3].
Cc [1]=new int [5].
Cc [2]=new int [7].
Int m, n, I, j, sum;
The Random rd=new Random ();
Scanner sc=new Scanner(System.in);
While (sc) hasNext ()) {
M=sc nextInt ();
N=sc. NextInt ();
Aa=new int [m] [n].
For (I=0; I & lt; m; I++) {
For (j=0; J & lt; n; J++) {
Aa [I] [j]=rd., nextInt (30);
System. The out. Printf (" % 3 d ", aa [I] [j]);
}
System.out.println();
}
For (I=0; I & lt; m; I++) {
Sum=0;
For (j=0; J & lt; n; J++)
The sum +=aa [I] [j];
System. The out. Println (" first "+ I +" line and is: "+ sum);
}
For (j=0; J & lt; n; J++) {
Sum=0;
For (I=0; I & lt; m; I++)
The sum +=aa [I] [j];
System. The out. Println (" first "+ j +" column and is: "+ sum);
}
}
Sc. The close ();

}

}
  • Related