Please help | read matrix travelling salesman problem

We are working on the travelling salesman problem in c++ for school, but we cannot figure out how to read the file we have to implement.
This is our txt file:

5
2 4 8 3
4 1 3
7 3
9

Where 5 is the number of cities and 2 is the distance between city 0 and 1, 4 between 0 and 2, 8 between 0 and 3 and 3 between 0 and 4 etcetera. We would like to make it a matrix like this:

0 2 4 8 3
2 0 4 1 3
4 4 0 7 3
8 1 7 0 9
3 3 3 9 0

We're working on it for hours now and we still can't figure out how to read this data from the file.. Could someone help us?
When you say 'we would like to make a matrix like this'. What do the values in the second matrix represent? Can you perhaps explain the question better / in a different way? It might not be your fault... I'm feeling a bit slow today, but I do believe I can help you, if I can only know what answer you're looking for... lol
The second matrix represents the distances between the cities:

0 2 4 8 3
2 0 4 1 3
4 4 0 7 3
8 1 7 0 9
3 3 3 9 0

Where the first row are the distances between city 0 and city 0 (which of course is zero), 1,2,3 and 4 (there are 5 cities, city 0, 1,2,3 and 4) .
Then the second row are the distances between city 1 and city 0,1,2,3 and 4
etc.
And we have to generate this matrix from the txt file:

5
2 4 8 3
4 1 3
7 3
9

Where the number 5 represents the total number of cities and the other numbers are numbers in the second matrix, which I made bold.
Btw we have to do this for different numbers of cities, so it should be a general program for n cities..
hmm so all you need to do is:

-Place zeros down the diagonal (distance from city 0 to city 0).
-Redraw each horizontal row vertically.

You can do this with a 2d array easily.

4
2 4 8
42
7

0 2 4 8
2 0 4 2
4 4 0 2
8 2 2 0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int array[4][4]; //Fill with zeros on empty slots and place numbers appropriately
//To obtain
/*
0 2 4 8 
0 0 4 2
0 0 0 2
0 0 0 0
*/
Then make each diagonally opposite number equal. For example: 
array[1][0] = array[0][1]; //Will do this... 
/*
0 2 4 8 
2 0 4 2
0 0 0 2
0 0 0 0*/
Topic archived. No new replies allowed.