Program to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural numbers from 1 to n*n, taking ‘n’ as input.
Program to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural numbers from 1 to n*n, taking ‘n’ as input. import java.util.*; class Circular_Matrix { //start of class public static void main() { Scanner sc=new Scanner(System.in); System.out.print("Enter the number of elements : "); int n=sc.nextInt(); int A[][]=new int[n][n]; int k=1, c1=0, c2=n-1, r1=0, r2=n-1; while(k<=n*n) { for(int i=c1;i<=c2;i++) ...











Comments
Post a Comment