[Solved] Draw a rectangle made with printf function, consisted of inner frames [closed]


As you have not posted code, I will also just verbally describe a possible algorithm.

You’ll need two embedded for loops. Outside loop for lines (y), inside loop for characters within line (x). Both shall run from zero to xmax and ymax, which are the numbers specified on the command line minus one.

Inside the body of the inner loop you have to find the frame. It depends on the distance to the edge. But which edge? The closest one. So this distance is the minimum of (x, y, xmax-x, ymax-y).

Then you print ‘a’ + distance. Additionally, after each line, you print a linefeed.

3

solved Draw a rectangle made with printf function, consisted of inner frames [closed]