1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Programming Question

Discussion in 'BBS Hangout' started by Lil Pun, Feb 4, 2004.

  1. LegendZ3

    LegendZ3 Member

    Joined:
    Nov 6, 2002
    Messages:
    4,196
    Likes Received:
    5
    ps: my aim is antic01dmi1k
     
  2. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    OK, I finally have source code for Fibonacci but it is in three seperate c++ files. Does anybody know how to implement these files into one C++ source code file? Also, is it possible to combine the fibonacci code with other code so that I can calculate Fibonacci as well as Factorial. I want to add factorial code to the Fibonnaci code so that it will do both, is that possible? I would really like to send these files to one of you if you are good with C++ through e-mail or messenger (Yahoo!, MSN, AIM, whatever).
     
  3. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    The main reason that people are telling you not to use recursion when calculating the Fibonacci sequence is because its the quintessential worst possible algorithm known to man. It's not so bad when you're computing the 5th Fibonacci number, but when you get up to say, the 100th, you're talking about a run time close to the lifespan of the universe.

    Maybe you'll never get tested on numbers that big, though. If you don't do it recursively, the other option is to solve it iteratively. Do you know the difference? A recursive function calls itself to acheive looping, and an iterative function will use while/for/do loops. (you can still have loops in a recursive function, but at some point the function will call itself again to repeat instructions)

    Recursive example (a stupid one that will add 10 to some x):
    int recursive (int x) {
    if (x < 10) return recursive (x+1);
    else return x;
    }

    Iterative example (does the same thing as the recursive example):
    int iterative (int x) {
    for (int i=0; i<10; i++) {
    x++;
    }
    return x;
    }
     
  4. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    You can message me if you want. I've been a CS Teaching Assistant for close to 4 years now, and I'm graduating in April, so everything is very fresh for me.

    my aim name is: getsongsfromlan
     
  5. wizkid83

    wizkid83 Member

    Joined:
    May 20, 2002
    Messages:
    6,347
    Likes Received:
    850
    God, I'm having programing horror flashbacks. But if I remember correctly the point of the class is just basically another program you call in your program, the syntax is more of a b*tch than the actual programing i think.
     
  6. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    Will you be on AIM between 1:00-2:00 PM today? How about around 7:00 PM tonight? I am very confused about this and eager for help.
     
  7. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    I'm on AIM right now if you want. I should be around 1-2 Houston time.
     
  8. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    The problem is I don't have the files here on my work PC, they are on my home PC. I'll try to contact you between 1-2, what about after 7:00 PM tonight?
     
  9. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    I should be around then. I might not be close to my computer, but I usually leave the messenger running, so if I see it then I'll stop and help. (wife willing) I'm an hour earlier than you so it should be fine.
     
  10. jw1144

    jw1144 Member

    Joined:
    Jul 29, 2002
    Messages:
    313
    Likes Received:
    3
    :D
     
  11. Woofer

    Woofer Member

    Joined:
    Oct 10, 2000
    Messages:
    3,995
    Likes Received:
    1
    Actually you can outsource it yourself. Go to www.rentacoder.com
    Some of the projects are obviously tasks for university courses.
     
  12. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    I don't want somebody to do the code for me, I want to figure it out myself but as I said my professor is from a different country and it's very difficult to understand him, even his emails. I just need some guidance is all.
     
  13. Woofer

    Woofer Member

    Joined:
    Oct 10, 2000
    Messages:
    3,995
    Likes Received:
    1
    I should have put a smiley, I was being facetious.
     
  14. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    Anybody know where I can find an example of a Java program that uses the Vector class? It doesn't have to be anything fancy.
     
  15. LegendZ3

    LegendZ3 Member

    Joined:
    Nov 6, 2002
    Messages:
    4,196
    Likes Received:
    5
    You meant the one-dimensional array?

    public class Java2601
    {
    public static void main(String args[])
    {
    System.out.println("\nJava2601.java\n");
    int list1[] = new int[5];
    char list2[] = new char[5];
    String list3[] = new String[5];

    for (int k = 0; k < 5; k++)
    System.out.println("list1[" + k + "] = " + list1[k]);
    System.out.println();

    for (int k = 0; k < 5; k++)
    System.out.println("list2[" + k + "] = " + list2[k]);
    System.out.println();

    for (int k = 0; k < 5; k++)
    System.out.println("list3[" + k + "] = " + list3[k]);
    System.out.println();
    }
    }
     
  16. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    class Something {
    int number;
    String attribute;

    public Something (int num, String attr) {
    number = num;
    attribute = attr;
    }

    public String toString() {
    return "number: " + number + " attribute: " + attribute;
    }
    }

    class Driver {
    public static void main (String [] args) {
    Vector vector = new Vector();
    Something something1 = new Something(2,"some attribute");
    Something something2 = new Something(3,"Lil Pun");
    vector.addElement(something1);
    vector.addElement(something2);
    System.out.println(vector.elementAt(0));
    }
    }
     
  17. AroundTheWorld

    Joined:
    Feb 3, 2000
    Messages:
    83,288
    Likes Received:
    62,283
    crap, this thread is a friggin classic.

    i didn't understand anything.

    yet, i know for sure, i know several people who could shake the requested code out of their butt in three milliseconds.
     
  18. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    No I need an example of a two-dimensional vector class.
     

Share This Page