Thread: Oops

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    4

    assignment

    My professor has given me this programming assignment to be done in C++ (which I have never really used, but I know the basic syntax) Here is the problem:
    We are given a chart with 10 cities and how long it takes to get from one to the other, we have to determine what would be the fifth shortest route to take and the third longest, visiting every city starting from 'A' and ending in 'A'.

    It looks to me like I'm going to have to make a vector to keep track of all of the trips, and to determine every trip possible I will need a permutations function (which I have already), and to keep track of all of the distances I would need an 8X8 matrix. Using this method, I do think I know everything that's going to have to done, but it just seems like a lot (to me), I just wanted to make sure I am on the right track before I get started. Also after I finish this, I'm going to have to write the program again in fortran, is that going to be a lot more difficult? Thanks for any help anybody offers!

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    "Using this method, I do think I know everything that's going to have to done, but it just seems like a lot (to me), I just wanted to make sure I am on the right track before I get started."

    Programming doesn't work that way. You make a plan, you start coding, and if needed you change your plan as you go along.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    It's always good to plan first.

    You should not need vectors. A 2-dimensional array (matrix) should do.

    I haven't really thought deeply about this... or drawn myself any pictures... but I think you need a 10 x 10 matirx, then you ignore 10 of 'em (point A to A, etc) Actually, you only need half of the matrix, because A-to-B is the same distance as B-to-A.

    Fortran shouldn't any more difficult. It all depends on which language the programmer is more familiar with. I don't remember any Fortran, but it seemed easier to learn than C/C++.

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    4

    Oops

    Oops, I meant 8 cities, I don't know why I said 10, anyway though, I planned to use the vector to keep track of the order in which the trips would take, because I need the 5th and 3rd not the fastest and longest... Thanks for the input!

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    4

    I give up

    This was supposed to be a reply to my other thread, but I didn't click reply, sorry everyone.

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> This was supposed to be a reply to my other thread,

    And now it is!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why C++ is not OOPS
    By noobcpp in forum C++ Programming
    Replies: 13
    Last Post: 10-20-2008, 01:20 PM
  2. Mouse... oops its Nouse
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 09-22-2004, 04:36 PM
  3. Oops, she did it again...
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-19-2004, 02:34 PM
  4. OOPS!!!! I need help please read+reply!
    By minime6696 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-14-2001, 02:51 PM