2,712 Posted Topics

Member Avatar for apanimesh061
Member Avatar for apanimesh061
0
160
Member Avatar for IndianaRonaldo

Given a very large large number( for example one with 1024 digits ), find all of its factors in polynomial time.

Member Avatar for mrnutty
0
104
Member Avatar for maybnxtseasn

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.

Member Avatar for Narue
0
160
Member Avatar for Noxer

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 …

Member Avatar for ravenous
0
625
Member Avatar for mattloto

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 …

Member Avatar for mrnutty
0
147
Member Avatar for sergent

Why not use std::string? You can compare numbers and access the individual characters.

Member Avatar for mrnutty
0
210
Member Avatar for daviddoria

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 …

Member Avatar for mrnutty
0
742
Member Avatar for bangor_boy

Whats the quantum time? I'll assume its one. Try posting your answers here instead of attachments.

Member Avatar for Momerath
0
155
Member Avatar for sdr001

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]

Member Avatar for sdr001
0
191
Member Avatar for Wakesta

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; …

Member Avatar for mrnutty
0
153
Member Avatar for ayan2587

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.

Member Avatar for mrnutty
0
124
Member Avatar for aragant
Member Avatar for jamesl22

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 …

Member Avatar for jamesl22
0
282
Member Avatar for Violet_82

[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 …

Member Avatar for Violet_82
0
4K
Member Avatar for cNew

Your algorithm isn't really mergesort, its just merge. It merges two sorted data. Check wiki for a mergesort implementation.

Member Avatar for Narue
0
211
Member Avatar for sergent

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 …

Member Avatar for mrnutty
0
255
Member Avatar for MarginOfBuffett

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]

Member Avatar for Narue
0
260
Member Avatar for stemiros

>>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.

Member Avatar for mrinal.s2008
0
2K
Member Avatar for PaulBird

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]

Member Avatar for frogboy77
0
251
Member Avatar for mrnutty

I got a big summer internship interview today. Wish me luck!!! I'm gonna need it.

Member Avatar for jingda
0
236
Member Avatar for Shruti4444
Member Avatar for flowerzink
Member Avatar for eman 22

Use the [i].get()[/i] method. Here is an example: [code] istream fileReader("filename.txt"); char byte; while( fileReader.get(byte) ){ cout << byte; } [/code]

Member Avatar for NathanOliver
0
85
Member Avatar for Ksadler818

>>[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?

Member Avatar for WaltP
0
195
Member Avatar for LevyDee

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 …

Member Avatar for mrnutty
0
127
Member Avatar for sergent

[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 …

Member Avatar for arkoenig
0
547
Member Avatar for ChaseRLewis

>>[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.

Member Avatar for rubberman
0
89
Member Avatar for jmalbornoz

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 …

Member Avatar for jmalbornoz
0
3K
Member Avatar for Gernicha

[URL="http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=image+loader+C%2B%2B"]gooooooooooooooogle[/URL]

Member Avatar for mrnutty
0
36
Member Avatar for IamAuser

Remember that Pointer-to-objects do not get initialized to null implicitly, you have to do that by your self

Member Avatar for IamAuser
0
271
Member Avatar for frogboy77

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 …

Member Avatar for jonsca
0
123
Member Avatar for comSysStudent

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]

Member Avatar for comSysStudent
0
192
Member Avatar for hawita

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 …

Member Avatar for hawita
0
138
Member Avatar for thecodepixie

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 …

Member Avatar for Arbus
0
164
Member Avatar for diedie

An example: [code] std::string expression = " (2*3) + 8/9"; //expression[0] = '('; //expression[1] = '2'; //expression[2] = '*' //...and so on [/code]

Member Avatar for WaltP
0
186
Member Avatar for Dexxta27

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 …

Member Avatar for Dexxta27
0
151
Member Avatar for llamaboy
Member Avatar for TailsTheFox

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

Member Avatar for VernonDozier
0
5K
Member Avatar for SeePlusPlus2

[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.

Member Avatar for arkoenig
0
152
Member Avatar for mrnutty

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, …

Member Avatar for susheelsundar
2
284
Member Avatar for jackmaverick1

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]

Member Avatar for pseudorandom21
0
355
Member Avatar for highflyer8

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 …

Member Avatar for royng
0
179
Member Avatar for subith86
Member Avatar for frogboy77

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?

Member Avatar for frogboy77
0
159
Member Avatar for maxstoto
Member Avatar for lochnessmonster

the buffer gets big as it needs to in order to store the input. It grows dynamically as it needs to.

Member Avatar for WaltP
0
168
Member Avatar for Labdabeta

For you example #2, isn't that undefined? You are( or will be) referencing a variable that is out of scope.

Member Avatar for mike_2000_17
0
150
Member Avatar for RyanMcMillan
Member Avatar for highflyer8

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 …

Member Avatar for mrnutty
0
162
Member Avatar for HashIncludeDotH

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 …

Member Avatar for HashIncludeDotH
0
1K

The End.