numbers square, Computer Engineering

Assignment Help:
Your professor wants you to fill a two-dimensional N by N matrix with some numbers by following a specific pattern. According to his explanation as in the figure below, you have to fill the whole matrix by starting from the upper left corner. And then you continue by growing the size of the square matrix one by one. You start by filling a 1 by 1 matrix, then a 2 by 2 matrix until the n by n matrix is filled.



So, in the example given above, you have to fill a 10 by 10 matrix starting from number 4. Then, you continue from the next column (downwards) and from the next row (right to left) by incrementing the number and by storing it in the current position in the array.

Question: Given the dimension of the final matrix and the starting number, print all the elements of the final matrix.

Input specification
You will be given two integer n and s ( 5 <= n <= 100 and 1 <= s <= 100 ) where n represents the dimension of the final matrix and s represents the starting number in the upper left corner.

Output specification
Show all of the elements of the final matrix separated by a single space as in the given examples.

Related Discussions:- numbers square

Explain priority interrupt, What is priority interrupt? A priority inte...

What is priority interrupt? A priority interrupt is an interrupt that establishes a priority over the various sources to verify which condition is to be serviced first when two

Characters in vi editor, What is the command used to replace many character...

What is the command used to replace many characters in Vi Editor? Ans) For replace most of the character in vi editor press esc key and then press R for change many character.

Decision trees - artificial intelligence, Decision Trees - Artificial intel...

Decision Trees - Artificial intelligence: Suppose you just ever do four things at the weekend: go shopping, watch a film, play tennis or just stay inside.  What you do depends

What is script-fu in gimp, Sript-Fu is the first GIMP scripting extension. ...

Sript-Fu is the first GIMP scripting extension. Extensions are split processes that communicate with the GIMP in the similar way that plug-ins do. The distinction is that extension

What are cosmic rays, Q. What are cosmic rays? The ionising radiation s...

Q. What are cosmic rays? The ionising radiation several times stronger than γ-rays entering the earth from all the directions from cosmic or interstellar space is known as cosm

How to write good assembly programs, Preparation of writing the program ...

Preparation of writing the program 1.  Write an algorithm for your program closer to assembly language. For instance the algorithm for preceding program will be: get NUM1

Draw a neat labelled diagram of the osi reference model, Draw a neat labell...

Draw a neat labelled diagram of the OSI reference model for computer networks showing all the layers and the communication subnet boundary. The computer network consists of all

Impact of information systems, What are the primary impacts of information ...

What are the primary impacts of information systems on an organization (employer, club, school, religious, etc..) for which you are familiar? What are the primary ways in which

Program, Write a program to find the area under the curve y = f(x) between ...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Illustrate about sharing of structure and behaviour, Illustrate about Shari...

Illustrate about Sharing of Structure and Behaviour  One of the reasons for the popularity of object-oriented techniques is that they promote sharing at different levels. Inher

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd