Compress Array From Lage To Short

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MoNnY
    New Member
    • Nov 2011
    • 3

    Compress Array From Lage To Short

    Hi Everyone :)

    My Q is About Array and Compress it

    If I Have An Array like :

    Code:
      Array[3][3];
    And Have Data Like :
    [020]
    [000]
    [001]

    and i want to Short It And write it without 0s and in another way like :

    Code:
     Array2[2][3[
    Like :
    [012]//the 0 to represent column and 1 to row ans 2 value
    [221]//the 2 to represent column and 2 to row ans 1 value


    that's mean the second array to find values places in Array // Without 0s

    hope you Get My Point

    See You Soon :)
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    What computer language are you using?
    What is the data type for Array?

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      You might want to read this: http://bytes.com/topic/c/insights/77...rrays-revealed

      Comment

      • MoNnY
        New Member
        • Nov 2011
        • 3

        #4
        What computer language are you using?
        What is the data type for Array?

        =============== ===========

        c++
        int

        thanx donbock


        You might want to read this: Arrays Revealed

        =============== =============== =============

        thanx weaknessforcats
        but i don't found what i want

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          So ... your Array is filled in a manner equivalent to this:
          Code:
          int Array[3][3] = { {0, 2, 0}, {0, 0, 0}, {0, 0, 1} };
          I don't understand what you want in Array2.

          Comment

          • johny10151981
            Top Contributor
            • Jan 2010
            • 1059

            #6
            Then your problem is compressing??

            What compressing method you want to apply?

            If you want to compress your array with ZLIB data format then download the zlib source code and build from it, its faster

            Comment

            • YarrOfDoom
              Recognized Expert Top Contributor
              • Aug 2007
              • 1243

              #7
              I believe the OP has an array mostly filled with zeroes and wants to convert it to a smaller array that contains the non-zero values and their coordinates.
              Don't have a clue what the actual question is though, unless it is "how do I do this?".

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                It looks like the OP wants an array of addresses that point to elements in the other array. That is, an array of pointers but I can't tell if this is correct.

                Comment

                • donbock
                  Recognized Expert Top Contributor
                  • Mar 2008
                  • 2427

                  #9
                  It looks like you want the second array to identify all of the nonzero cells in Array. That is, something equivalent to this:
                  Code:
                  struct s {
                     int row;
                     int col;
                     int value;
                     };
                  struct s Array2[9];
                  Each entry in Array2 identifies the row/column location of a nonzero cell in Array and also the value of that cell. I propose using a structure array rather than a 3-dimensional array to enhance program clarity. I suggest declaring Array2 with 9 elements so that it is big enough to handle the worst case -- when all cells in Array are nonzero. Array2 will usually be only partially full; you need some way to recognize which is the last meaningful entry in Array2.

                  Now you need to write a program that traverses Array, copying information about each nonzero cell to Array2.

                  Comment

                  • MoNnY
                    New Member
                    • Nov 2011
                    • 3

                    #10
                    Thanks a Lot Guys .

                    That's What You Says Help Me .

                    Thanks Again For All of You Friends .

                    Comment

                    Working...