Playing with arrays


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Playing with arrays

  1. #1
    Join Date
    May 2005
    Posts
    115

    Playing with arrays

    I want to read from a file test.txt with the contents

    Legend:
    ABCD

    DistanceMatrix:
    0
    10 0
    11 12 0
    13 14 15 0

    My idea is to first pass all values in the distance matrix into a temp[] array, thus temp will contain [0 10 0 11 12 0 13 14 15 0]

    Then, i want to pass these values in temp into another multidimensional array distanceMatrix[][].

    Here is the code
    Code:
    			int x=0;
    			for(int i=0;i<size;i++){
    				int y=0;
    
    				distanceTable[x][y]=temp[i];
    
    				if(distanceTable[x][y]==0.0)
    					x++;
    				else
    					y++;
    			}
    The idea is to increment y after a value of 0.0 has been passed into distanceMatrix, to create the result of
    Code:
    distanceMatrix[0][0]=0.0
    distanceMatrix[0][1]=0.0
    distanceMatrix[0][2]=0.0
    distanceMatrix[0][3]=0.0
    distanceMatrix[1][0]=10.0
    distanceMatrix[1][1]=0.0
    distanceMatrix[1][2]=0.0
    distanceMatrix[1][3]=0.0
    distanceMatrix[2][0]=11.0
    distanceMatrix[2][1]=12.0
    distanceMatrix[2][2]=0.0
    distanceMatrix[2][3]=0.0
    distanceMatrix[3][0]=13.0
    distanceMatrix[3][1]=14.0
    distanceMatrix[3][2]=15.0
    distanceMatrix[3][3]=0.0
    However, with my code, the result i get with my distanceMatrix array are all zeros. What is the problem?

  2. #2
    Join Date
    May 2005
    Posts
    115
    found the answer...

    cant delete thread...

Similar Threads

  1. Control Arrays in VB.NET
    By Gary Nelson in forum .NET
    Replies: 277
    Last Post: 10-01-2003, 01:00 AM
  2. Copy/Duplicate Arrays
    By Steve Cochran in forum .NET
    Replies: 8
    Last Post: 10-18-2002, 01:10 PM
  3. Replies: 15
    Last Post: 05-09-2001, 05:40 AM
  4. VB Arrays and memory allocation
    By Brian Leung in forum VB Classic
    Replies: 12
    Last Post: 06-20-2000, 04:06 PM
  5. VB Arrays and memory allocation
    By Brian Leung in forum VB Classic
    Replies: 0
    Last Post: 06-20-2000, 10:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center