944,162 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 6887
  • Perl RSS
Jan 31st, 2007
0

How to make matrix?

Expand Post »
I am total novice, but I must solve this problem very quick and need help. Problem:I’ve been given a file
1 2 15
1 3 16
2 3 20
and so on…First two values of the input file represents graph nodes and the third one is distance between them. I know the number of nodes(in previous example number of nodes is 4, counting starts from 0)
I need perl code that makes a matrix that looks like this:
0 0 0 0
0 0 15 16
0 15 0 20
0 16 20 0
Thanks in advance!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jovimarko is offline Offline
1 posts
since Jan 2007
Feb 1st, 2007
0

Re: How to make matrix?

You can do many things, the easiest of which to describe would be to use an array and fill it with nested for loops. As long as you have the same number of data in each row, accessing the data is a simple matter of dividing your array into n parts.

2x4 matrix:

[][][][]
()()()()

array structure:
[][][][]()()()()
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Execute unix command from perl running on windows
Next Thread in Perl Forum Timeline: Strange issue with arrays





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC