2,712 Posted Topics
Re: Yep If I am reading correctly, then you need to check the collision between objects in your room, so they "interact" with each other. | |
Re: Can you just clear the screen after the call? | |
Re: Use the ? : operator. | |
Re: >>Does that initialize all of the elements to zero? I guess so. I haven't seen that before either. | |
Re: read [URL="http://www.cplusplus.com/doc/tutorial/files/"] this[/URL] | |
Re: replace the && with the ||. You wan't the loop to run if either currentX OR currentY is not equal to toX or toY, respectively. Also take out the else { currentX-- } and else{ currentY-- } there is not point since say currentX will not increment if its 100. | |
Re: 1) First create a prime number generator 2) The adjust it accodignly to what you need it. A prime number is one where its 2>= | n | < MAX, n != even, n is evenly divisible its self and 1 only. A few primes are 2,3,5,7,11. 5 is a … | |
Re: Make use of function. 1) Create a function that does this f(34)=17 , for a given value. Make sure it works. For use a for loop with from start to finish and just call that function. It will be more readable, better code/practice and you will get a better grade. | |
Re: I feel nice today so I will help you : Define a Double Linked Lists EmpRank where the data should be of type integer. [code] #include<iostream > using namespace std; int main(){ cout<<"Here is a double linked list called EmpRank"; cout<<" that I got from daniweb forumn, Please give me … | |
Re: This gets rid of the error in visual studio 2008, but it doesn't mean your program works. Try it : [code] #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { vector<string> gameName; int choice = 0; string game = " "; vector<string>::iterator myIterator; vector<string>::const_iterator iter; … | |
Re: Break the pattern down. Linearly : some numbers | middle number| some number reversed [code] 1 2 |3| 2 3 4 |5| 4 3 4 5 6 |7| 6 5 4 5 6 7 8 |9| 8 7 6 5 6 7 8 9 0 |1| 0 9 8 7 … | |
Re: Most likely its raw definition will be something like this : [code] void swap(char& a, char& b) { char temp = a; a = b; b = temp; } [/code] Think of whats happening. | |
Re: In bubble sort when every you swap print out the array. In selection sort, whenever you swap print out the array. Also your functions : showArray1 and showArray2 is repetitive to each other. You only need one of them, and pass array1 or array2 whenever you wan't to print them … | |
Re: If this is what you are looking for : [code] enter a word : hello hello backwords is : olleh [/code] then all you have to do is use a for loop, start from strlen(str)-1 , to >= 0 and print out at index i. | |
Re: It is converting it correctly. It just doesn't display the trailing 0's. If you want to see the trailing 0's then you can use [URL="http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html"]DecimalFormat[/URL] | |
Re: Just create some functions, for example a function for addition would look like this : [code] int addNumbers(int number1, int number2){ return number1 + number2; } [/code] And you can do similar for other operation. It might seem like its not worth it but doing this will make your program … | |
Re: How to use functions : 1) Declare a prototype . Ex : [code] //int is the return type //calculateBonus is the function's name //int number is its argument // the semicolon " ; " means its a prototype int calculateBonus(int number); [/code] 2) Give it a body outside of main … | |
Re: How are you getting the sprite to be displayed, meaning what graphics library are you using? | |
[B]If yu wer strnded in a is_land ten wat wud u brin , u gt at mst fiv tings and no triky buzzness, understand?[/B] I would bring (1)Angelina Jolie, then my (2)laptop (with infinite battery life, that catches wifi from earth to outerspace), a (3)knife, an a (4)manual on how … | |
Re: [QUOTE=nu2cpp;1050330]Hi Guys, I am trying to reverse engineer some of the openGl function into pure c++ and need some help. I can't use openGL but need to do some of the stuff it does. I am trying to figure out how to code glViewPort(...) in c++. Any help in this … | |
Re: Good. Now try to be more organized and start learning classes. Once you have a "good" grasp, convert the code into objects. | |
Re: [QUOTE=mohammad nour;1050577]I wont it like that [CODE]* * * * * * * * * * * *[/CODE][/QUOTE] By looking at the figure,what can you tell me about the; line by line? | |
Re: >>void class::getNumberOfoBJECTS(HOW DO I PASS FILENAME HERE?) << I guess you were not listening. [code] void class::getNumberOfoBJECTS(string fileName) { fstream* file = new fstream(fileName.c_str(), fstream::in | fstream::binary); [/code] | |
Re: There are many ways, I will show you one way : [code] #include <iostream> #include <sstream> #include <string> using namespace std; void extractWords(string source, string * wordArray, const int size) { stringstream seperate; //our stream object that will extract each word seperate << source; //insert what we want to extract … | |
Re: If practice is what you want then [URL="http://hkn.eecs.berkeley.edu/~dyoo/cs3/recursion-problems.pdf"]google1[/URL] [URL="http://hkn.eecs.berkeley.edu/~dyoo/cs3/recursion-problems-2.pdf"]google2[/URL] | |
Re: Take it step by step. create this part first : [code] Enter values in first array: a h b c u v I j k e Enter values in Second array: y u d f g k I w q a [/code] Then create this part : [code] Merged array: … | |
Re: Clock() is not "that" accurate but it should be accurate enough, unless you need more accuracy. Try it out first and then decide. [code] #include<ctime> #include<iostream> using namespace std; int main() { long clk_strt = clock(); // some code goes here to test long clk_end = clock(); cout<<"Difference in milliseconds … | |
Re: Its undefined, google sequence points. Aia I like your avatar. | |
Re: I think whats more important is what the safer way. | |
Re: [QUOTE=pecet;1048509]I have a question. Lines #21, #22 and #23: [CODE] employee *first=NULL; first=new employee; if(first==NULL){ //... [/CODE] If you allocate memory for pointer 'first', is that possible for 'first' to be NULL unless you get some exception?[/QUOTE] Yes, but what he is doing is wrong. If you use nothrow when … | |
Re: just a simple if statement will do before the calculation. [code] if input is -1 then return 0 else carry on with the calculation. [/code] | |
Re: This one is pretty simple : [code] void bubbleSort(vector<int>& vec, bool sortAccendingOrder = true){ for(int i = 0; i < vec.size();i++) for(int j = i+1; j < vec.size(); j++) { if(sortAccendingOrder) { if(vec[i] > vec[j]) std::swap(vec[i],vec[j]); } else if(vec[i] < vec[j]) //else decendingOrder std::swap(vec[i],vec[j]); } } [/code] | |
Re: For your cube array do your calculation like this : [code] for(int i = 0; i < Size; i++){ values[i] = values[i] * sqrt( float(values[i]) ); } [/code] That way you multiply your square number by its root, which is the original number you inputed. | |
Re: From what my debugger is telling me, you have a stack overflow on line 544 | |
Re: You have : 1 2 3 2 3 1 3 1 2 Think of it as a variable : a b c b c a c a b 1) you can see that they are rotated to the left. a b c //original b c a //rotated to the left … | |
Re: You have this : [code] return 0; system("PAUSE"); return EXIT_SUCCESS; [/code] Take out the return 0 , since return EXIT_SUCCESS is the same thing. So you should now have this : [code] system("PAUSE"); return EXIT_SUCCESS; [/code] | |
Re: Do you understand this ? [CODE] if( something) { do something } else if( it is something else ) { then do something else } else if( it is something else) { then do something else }[/CODE] | |
Re: You could sort the array and the check if adjacent values are the same. | |
Re: 1) use Code tags. 2) The second one. Its more reusable. | |
The function adds two large numeric string together, like "12345667" + "12345678" = ? It does not have complete error checking, I'll leave that up to you. It should work but I am prone to bugs, so do advise if bugs are found. Included are also helper function that helps … | |
Re: try char * retail. But you will have to allocate memory before the use of it. BTW why do you need it to be global? | |
Re: in your reverse function, what happens if num is less than 0? What would the function return? Get the input as a string and print the string backwards. Makes sure the string contains numeric data if you want. | |
Re: Have a test condition in your for loop. In psuedocode : [code] for i = 0 untill MAX{ pick1 = random number pick2 = random number while(pick2 == pick1 ) pick2 = another random number pick3 = random number while(pick3 == pick2 or pick3 == pick1) pick3 = another random … | |
Re: They have given you the answer, but let me expand on that : Your prototype for fillArray is this : [code]int fillArray(int);//Trying to make a fn that fills an array[/code] What does that mean ? It says that fillArray takes an int variable and returns an int variable. What you … | |
Re: Wow. Imagine how much process a game could save by using this technique. | |
Re: ouch that hurts my eyes. WHY aren't you using loops ? [code] do { for(int i = 0; i < 15; i++){ cout<<"|"; for(int j = 0; j < 15; j++){ cout<<intmap[i][j]; } cout<<"|"; } //rest of you code for input }while(true) [/code] Your teacher would fail you if she … |
The End.