c/c++

Problem Statement :-
An ant is standing at the left most corner in a room(matrix of order m*n). It has a sack of sugar cubes,,with cubes having numbers written on them. The ant goes on dropping the sugar cubes in ascending order while moving from that corner at the side of the wall in spiral format. As soon as it finishes one round of the room the dropped cubes seem to be a new wall for the ant. The ant again repeats the entire move till the entire room gets filled with a single layer of cubes. Represent it in the form of 2-D matrix.

  1. 👍 0
  2. 👎 0
  3. 👁 79
  1. Fun problem, a little different from most other standard ones.

    11*24*23*22*21*20
    12*25*26*27*28*19
    13*14*15*16*17*18

    Like that?

    You can iterate through with two variables, i,j so that if i=j, you switch directions. (note: C/C++ arrays are zero-based).

    1. 👍 0
    2. 👎 0
    posted by MathMate

Respond to this Question

First Name

Your Response

Similar Questions

  1. english

    Which sentence below contains a dangling modifier? Keeping to himself, the corner of the room seemed like a good place to stand. John kept to himself by standing in the corner. Standing in the corner, John kept to himself. Keeping

    asked by christopher on April 19, 2010
  2. physics

    a fly moves from one corner of the floor of a room and you are standing opposite corner into the room .Describe the displacement of the fly when it covers half of the distance.

    asked by hassan on June 2, 2011
  3. physics

    a fly moves from one corner of the floor of a room and you are standing opposite corner into the room .Describe the displacement of the fly when it covers half of the distance.

    asked by hassan on June 2, 2011
  4. algebra

    When i have a matrix 4 X 4 and i have to multiply it by a 4 X 3 i know that the product size has to be a 4x 3 so do i do a row times column or how ? It's easiest to learn using the notations for tensors. For any matrix X denote

    asked by student on June 17, 2007
  5. Physics

    I don't really know where to start on the problem. Would I use V = k(q/r)? But what would I do afterwards. Much explanation on how to go about the problem is much appreciated. Thank you. 1) Three point charges are arranged at the

    asked by Aria on February 8, 2015
  6. Physics 1112 Electric charge

    As shown in the figure, a square has sides of 8.0 cm with a charge of +6.0 µC at one corner (a) and with charges of -2.0 µC at the remaining three corners (b, c, and d). The figure is just a square with no measurements. Corner a

    asked by Sar on August 21, 2010
  7. Math

    Given the following matrix A, find an invertible matrix U so that UA is equal to the reduced row-echelon form of A: You can resize a matrix (when appropriate) by clicking and dragging the bottom-right corner of the matrix. A = 3 3

    asked by valarie on October 21, 2018
  8. Physics

    An ant walks on a piece of graph paper straight along the x axis a distance of 10.0 cm in 2.00 s. It then turns left 30.0 degrees and walks in a straight line another 10.0 cm in 1.90 s. Finally, it turns another 70.0 degrees to

    asked by Kyle on July 21, 2011
  9. Algebra

    Use the figure to answer the following questions: ( a triangle with the bottom right corner of it labeled L with (1, 1) x y coordinates. Left corner of the triangle is labeled M at the (-3, 1) coordinates. the top of the triangle

    asked by Anonymous on June 7, 2017
  10. physics

    A fly lands on one wall of a room. The lower left-hand corner of the wall is selected as the origin of a two-dimensional Cartesian coordinate system. The fly is located at the point having coordinates (1.80, 1.15) m. (a) How far

    asked by Nancy on October 4, 2009

More Similar Questions