Please help me to solv this program known circular matrix
input=3
output like
1 2 3
8 9 4
7 6 5
Well to solve this look a the matrix format... when we give an input the maximum number within the matrix is input square... that is if input is n then the maximum number feeded into the matrix will be n suqare.
Assume :
Array = a[][];
Input = n;
sq = n squared;
So take a variable num=0 and you have your input squared that is sq
while(num<sq)
{
// Coded for loops for traversal required,you may need upto 4 for //loops
}
Well, let's say you've declared a 2D matrix as the following: int matrix[n][n];
How would you write numbers around the border?
1 2 3 4 5
16 6
15 7
14 8
13 12 11 10 9
Now think of a circular matrix as a set of these rings, ever decreasing in size until the center of the matrix is reached. Once you've figured this out you'll have solved the problem.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.