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).
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; }
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
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.
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.
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?
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.
Actually you can outsource it yourself. Go to www.rentacoder.com Some of the projects are obviously tasks for university courses.
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.
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.
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=java+vector+example http://www.scar.toronto.edu/~andria/a06w01/tut/t9/vectorsHandout.html
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(); } }
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)); } }
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.