JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
public class Program
{ public static int fmatrix[][];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Size of the matrix:");
int number = sc.nextInt();
System.out.println("Reverse diagonal filled matrix of \nsize "+number+" x "+number);
fmatrix = new int[number][number] ;
for (int[] eachRow : matrix(number)) {
System.out.print("\n");
for (int eachNumber : eachRow) {
System.out.format(" %3d",eachNumber);
}
}
}//End of Main
//Preparing the matrix
public static int[][] matrix(int size)
{
int element =1,col=0,row=0;
for(col=size-1;col>=0;col--){
for(row=0;col<size;row++)
{fmatrix[row][col++]=element++;}
col=size-row;
}
for(row=1;row<size;row++){
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run