2,712 Posted Topics
Re: Its just a warning, goto the last line of the file and press enter. | |
Re: Given a very large large number( for example one with 1024 digits ), find all of its factors in polynomial time. | |
Re: When you create an array class, if you overload the [] operator, then you need to return by reference and return by const reference. So in some situation, it is necessary. | |
Re: He told you why it doesn't compile. The vector contains ints. ints has no member functions. So when you call vector.begin() it returns an iterator that points to a list of ints. And when you use the arrow operator on the iterator, it deferences the iterator, thus 'returning' ints. And … | |
Re: You should provide default initialization for the Point class as so : [code] class Point{ double x_,y_; public: Point( double x = 0.0 , double y = 0.0) : x_(x) , y_(y) //use initialization list to initialize variables {} }; [/code] the problem with your code what that there was … | |
Re: Why not use std::string? You can compare numbers and access the individual characters. | |
Re: Is the equations always linear? Or polynomial? Assuming its linear equation then a good way to solve the problem is to first just add/subtract/multiply/divide all possible numbers in the equation, then all your left with is a equation of the form, [i] AW + B = C [/i] where W … | |
Re: Whats the quantum time? I'll assume its one. Try posting your answers here instead of attachments. | |
Re: Make sure you have at least this : [code] #include <vector> using std::vector; struct B{}; template<typename T> struct Node{}; int main(){ vector< vector< Node<B> > > table; return 0; [/code] | |
Re: I would change everything. More specifically, stop the recursion. Here is a sample : [code] #include <cctype> //#include ... //returns the difficulty level else returns string::npos if fails int getDifficultyLevel(const char *msg){ const std::string difMap = "EAH"; char ans = 0; cout << msg; return difMap.find( toupper(ans) ) + 1; … | |
Re: Note std::vector<bool> is depreciated. Its creation was pointless and a mistake. std::vector<char> is a better choice versus std::vector<bool>. But using std::bitset would be better choice than either one depending on the need. | |
Re: Why are you not using recursion? | |
Re: Just interpolate between the starting height and the ending height. And you will get a smooth function. Afterwards, apply verlet integration for smooth transitioning. In short, just animate it crouching. But realize that crouching shouldn't take much cpu. So another suggestion is to have something like this : [code] void … | |
Re: [QUOTE=MattyRobot;1536481]saw that Narue posted first but it still adds a bit more info no. srand sets the seed, it doesnt generate random numbers. the seed is a number that rand uses to generate random numbers. rand potentially generates large numbers but some maths is all you need to put some … | |
Re: Your algorithm isn't really mergesort, its just merge. It merges two sorted data. Check wiki for a mergesort implementation. | |
Re: Note that usually you would initialize variables in the constructors like so : [code] class Point{ private: int x_, y_; public: Point(int x , int y) : x_(x) , y_(y) //called an initializer list { } }; [/code] There is something you have to remember about the above though. It … | |
Re: What are the errors exactly? Make sure you include safe guards in the header file. For example : [code] #ifndef SONG_H #define SONG_H class Song{...} #endif [/code] | |
Re: >>Is there a way I can find out which derived type 'baseItt' is pointing to? I need this to help me with saving and loading in my program. Consider having a save function for each class instead. | |
Re: As suggested, a simple getline would get a line. Here is an example : [code] std::string input; getline(cin,input); //now input contains everything the user entered [/code] | |
I got a big summer internship interview today. Wish me luck!!! I'm gonna need it. | |
Re: Use a map or a set | |
Re: Use the [i].get()[/i] method. Here is an example: [code] istream fileReader("filename.txt"); char byte; while( fileReader.get(byte) ){ cout << byte; } [/code] | |
Re: >>[B]I am just looking for an example of how I can count the occurance of each number in the array numbers and assign that value to the count array. [/B] what ideas do you have? Does not have to be code, just a general idea? | |
Re: The manager should use the interface provided by the car. Even if there would be an extra call, it better encapsulates and is easier to maintain and debug, if only one function controls the movement of the car. So if you make different type of parking manager, you can use … | |
Re: [B]Software reasons:[/B] - It reduces code readability. - It produces inefficient code. - It makes code maintenance harder - ...probably many more. [b]Hardware reasons: [/b] - It is inefficient. - Branch statement are one of the most inefficient operations, and using many of those makes the hardware work more, when … | |
Re: >>[B]By definition on the standard.[/B] just to clarify, usually the standard are terminals in computers, but for other things, it could be definitely something else. | |
Re: You can create a struct whose sole purpose if to share const global variables, for example : [code] struct EnvironmentConstants{ static const int TIME_STEP = 1; //in sec static const int SCREEN_WIDTH = 100; //in pixels //.. and so on }; [/code] and call it like so : [code] void … | |
Re: [URL="http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=image+loader+C%2B%2B"]gooooooooooooooogle[/URL] | |
Re: Remember that Pointer-to-objects do not get initialized to null implicitly, you have to do that by your self | |
Re: Hey look at it this way, if thats what your competing with, then you're golden. People these days are just pure virtual const lazy. They have no intention to do the actual research and learn from it. But the bottom line I believe is that they have no passion for … | |
Re: I think your printing loop is incorrect, try doing this : [code] list<nonZero>::iterator j; list< list<nonZero> >::iterator i; for(i = rows.begin(); i != rows.end(); i++) { for(j = i->begin();j != i->end(); j++) { cout<<(*j).getColumn()<<" "<<(*j).getValue()<<" "; } cout<<endl; } [/code] | |
Re: some hints/psuedocode 1) create a std::stack of strings 2) Either read words one by one, ending with a sentential value or read the whole sentence 3) If reading words one by one, just add it to the stack else if reading the whole sentence you will have to do some … | |
Re: yes using a condition loop : [code] for(int i = 0; i < size; ++i){ for(int j = 0; j < size; ++j){ if(grid[i][j] == 0) cout << " "; else cout << grid[i][j]; } cout << endl; } [/code] in your loop you go from i = 0 to … | |
Re: An example: [code] std::string expression = " (2*3) + 8/9"; //expression[0] = '('; //expression[1] = '2'; //expression[2] = '*' //...and so on [/code] | |
Re: Yea the problem is that when the user enters 'y' or 'Y', he is actually entering that plus a newline character. The getline reads the newline character as a valid input, thus it gives you no opportunity to input a second time. One solution is to use cin.ignore() before the … | |
| |
Re: If ur on windows, use [I]Sleep[/I](milliseconds) located on windows.h. If ur on linux use [I]sleep[/I](seconds) located on unistd.h | |
Re: [B]Also, static variables are initialized to 0, for basic types, by default.[/B] really? I thought you had to explicitly initialize them or else it would be a linkage error. So there is no default initialization. | |
I want you to name one thing that you really want and is plausible( not some ridiculous wish) and fair, and tell me whats stopping you from getting it? And then I want you to go and get it!!! Fight through the walls and barriers and grab the prize!!! Yesterday, … | |
Re: Your probably using it wrong. Try this : [code] #include <ctime> #include <iostream> using namespace std; int main(){ srand( time(0) ); //seed with different number each execution for(int i = 0; i < 10; ++i) cout << rand() << endl; [/code] | |
Re: I think OP is analyzing it way too much. there is no reason why you should rewrite the statement again. Its perfectly clear with its intentions. I think the problem is that you are confused about the theory. You need to just get more practice in first. Then the theory … | |
Re: I use to do it, got busy with other stuff. Not sure how many I solved but passed level 1. What problem are you stuck on? | |
Re: How are you representing the binary numbers? | |
Re: the buffer gets big as it needs to in order to store the input. It grows dynamically as it needs to. | |
Re: For you example #2, isn't that undefined? You are( or will be) referencing a variable that is out of scope. | |
Re: Just a comment. I find your hierarchy unneeded and wrong. You can easily make a template vector class for the general case, and then typedef certain instantiation of the template vector for easier use. And have regular function work with the generic template vectors. As a general rule, choose composition … | |
Re: For the zero problem you can have a cutoff value. Example : [code] float bandwidthCuttoff(const float value, const float width = 0.000001f){ if(-width <= value && value <= width) return 0.0f; else return value; } [/code] then you just pass the j (imaginary part) to this function to make a … |
The End.