CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Feb 2012
    Posts
    6

    Sparse 2 dimensional array

    Hello

    i created a program which uses Sparse 2 dimensional array, but i am not sure if i did it in the right way .

    this is the instruction i have:
    Create a constructor and a destructor. The constructor should take as input the size of the array (consider only square NxN arrays, so only one dimension is needed) and the thickness of the ribbon. To make this precise, if supplied with a thickness parameter t, you may assume that the element [0,t] (i.e. the (t+1)-th element of the first row) is where the useless area begins on the right. Similarly, the element [t,0] is where the useless area begins on the left. The border of the useless areas moves diagonally down and to the right, i.e. it consists of [1,t+1],[2,t+2],... and [t+1,1],[t+2,2],... The above example has thickness 3.
    The space for the 2-d array should be dynamically allocated and must be large enough to fit the useful data only.
    Create methods for random read and write access to the array as in the case of 1-d arrays.
    Overload the [] and << operators, as in the case of 1-d arrays. Think carefully about what the [] operator should return and how it should work. Ideally we would like this to behave in a manner similar to standard 2-d arrays (i.e. accessing elements in the normal way, like x[5][6]).

    please comment

    thank you
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured