2,712 Posted Topics

Member Avatar for aswin cp

Then go for, Lucas series. The only difference is the starting value. For fibonacci f(0) = 1, and f(1) = 1. Then its defined recursively as f(n) = f(n-1) + f(n-2), where n >=2. For Lucus series, f(0) = 2, and f(1) = 1, then its defined recursively as f(n) …

Member Avatar for mrnutty
0
1K
Member Avatar for martin_dore

Because as of right now you have to include the definition of the template class in the same file as the template header. If your compiler supports the keyword export, then you can separate them.

Member Avatar for martin_dore
0
108
Member Avatar for bori02082009

Or just get it as a string and see what it contains. For example : [code] string number; cin >> number; //say user entered "123" int a = number[0] - '0'; //a = 1 int b = number[1] = '0'; //a = 2 int c = number[2] = '0'; //a …

Member Avatar for abdelhakeem
0
166
Member Avatar for ef32

Make your first for loop like so : [code] for ( i=2;i<=40;i++)[/code] Then make your second for loop like so [code] for(i2=2; i2<i; i2++)[/code] The main problem is that you are printing inside the loop. Print outside. You overall loop could look like this : [code] int i = 0, …

Member Avatar for mrnutty
0
128
Member Avatar for vijaysoft1

[QUOTE=vijaysoft1;1134776]I am stuck with one problem , please anyone help me to do this . The question is Write a function to modify a list ( [I]one dimensional array[/I] ) of numbers such that every number is replaced by the average of its immediate neighbours ( [I]the value just above …

Member Avatar for mrnutty
0
273
Member Avatar for rena0514

This is wrong right of the back, "while (found=false && first<=last)". This is also wrong : [code] else if(searchValue>array[midpoint]) last=midpoint-1; else first=midpoint+1; [/code] Any clue why?

Member Avatar for mrnutty
0
87
Member Avatar for restrictment

Its good. The source is just not so flexible. You should separate it into files. Make use of structures, if you know how. You use mostly brute force, even with variables. Also do not use magic numbers, use constants, so its more readable and clear. Your source has a lot …

Member Avatar for rom87
2
922
Member Avatar for corby

>>[B] can anyone help me initialize this array with nested for loops?[/B] Do you know how to do it for a single for loop, i.e initialize say an Array[4] using a for loop?

Member Avatar for mrnutty
0
111
Member Avatar for codrguy

The inner loop is O(n^2), the most outer loop is log(n) [ I think ], so I would guess its log(n)*O(n^2).

Member Avatar for mrnutty
0
61
Member Avatar for mmasny

We're not physics. Post your code! Its probably something wrong with your program. Maybe the "1" in "104" is your boolean variable and the 04 is something else.

Member Avatar for mitrmkar
0
198
Member Avatar for suncica2222

Try to make your own using the ctime header. Here is some starter code [code] class Timer{ private: long startTime; long endTime; public: Timer() { startTime = endTime = clock(); } void startTimer(){ } void stopTimer(){ } long getElapsedMilliSeconds(){ } long getElapsedSeconds(){ return getElapsedMilliSeconds() * CLOCKS_PER_SEC; } float getElapsedMinutes(){ return …

Member Avatar for suncica2222
0
149
Member Avatar for mrnutty

We are all tired of from our daily lives. So I suggest to sit back and play this game. I present here a hangman game( text version ) for your enjoyment. There might be some bugs as I haven't throughly tested it, so sorry if you find it( I'm sure …

Member Avatar for mrnutty
1
290
Member Avatar for casjackkwok2001
Member Avatar for corby

This [CODE]void setDrawRectangleBorder() { char border; cout << "Enter the character you would like to see as the border of the rectangle:"; cin >> border; }[/CODE] Does not do anything useful.

Member Avatar for EngSara
0
144
Member Avatar for zhaviere

You need to realize the conversion between 2d array and 1d array. Namely, that 1D_Row = 2dRow * MAX_ROW + 2D_Column; In code it would look like this : [code] for(int row = 0; row < MAX_ROW; ++row){ for(int col = 0; col < MAX_COL; ++col){ Array1D[col + row*MAX_ROW] = …

Member Avatar for mrnutty
0
2K
Member Avatar for MrYrm

In recursion there are 2 main things : 1) basis : 2) Induction. In you recursive, you have provided the Induction, namely f() = f(), but you have not provided a basis case. Here is an example of a recursion function. Again, a recursion function has a basis and the …

Member Avatar for Stefano Mtangoo
0
122
Member Avatar for crocodal21

I really do wan't to help you, but I can't. Your code is hard to read. I would recommend you to indent your code. Then give it a try and see what happens. Then maybe shorten it as much as possible to show us what problem you are having.

Member Avatar for crocodal21
0
482
Member Avatar for bobsta

>>[B]Anyways you should be able to fix the problem you have by declaring pBeam in a global scope (by declaring it outside of functions at the top of your file).[/B] You should but that is not a good solution. Don't start of learning bad practices. It will only come back …

Member Avatar for bobsta
0
242
Member Avatar for mmasny

The warnings tells a thousand words : [code] 30 [Warning] ` class Kontrolka' only defines private constructors and has no friends 33 [Warning] ` class KontrolkaAtomowa' only defines private constructors and has no friends 36 `Kontrolka' with only non-default constructor in class without a constructor [/code] Realize that in a …

Member Avatar for mrnutty
0
170
Member Avatar for wilsonz91

Use cout and cin instead of the C function printf and scanf, after all this is C++. Using rand, you have the correct idea, but you also have to seed it. Insert this code : srand( time(0) ) at the very beginning of your main. That code seeds the rand …

Member Avatar for wilsonz91
1
201
Member Avatar for JustSuds

The problem is that D3DXVECTOR3 is not being found for whatever reason. Have you linked ALL of the lib and headers? Maybe something got corrupted. >>[B]I've actually been building this from a tutorial (its beginners DirectX for C++ Veterans) where the source code compiles and runs perfectly, yet, even pasting …

Member Avatar for JustSuds
0
191
Member Avatar for MatthewSedam

>>[B]if (answer!=df1/df2)[/B] what happens if df2 > df1. For example say df1 = 20 and df2 40 answer = df1 / sf2 = 20 / 40 = 1/2 = 0.5 Thats a fraction. And your variables are of type Int. That means the real answer gets truncated. Which means if …

Member Avatar for mrnutty
0
188
Member Avatar for mikabark

Use std::copy. If not then create your own like so. [CODE]#include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std; template<typename Container> void print(const Container c){ Container::const_iterator itr = c.begin(); cout << "{ "; while(itr != c.end()){ cout << *itr++ << " "; } cout << "}"<<endl; } template<typename …

Member Avatar for mikabark
0
151
Member Avatar for shankhs

Using only C++ won't do this for you. You will have to use external libraries and such. For example using win32, you probably can get control of the mouse, maybe. Using audio libraries, you can play an manipulate sounds. Using an image library, you can manipulate images. Using a graphics …

Member Avatar for tkud
0
626
Member Avatar for PDB1982

>>[B]But, I've been told that srand() will produce a better random number[/B] Whomever told that to you should not talk about programming anymore. All srand does is seed the random number generator. [B]>>a good one is the mesner twister >>It's called the Mersenne Twister.[/B] Yes that is better than rand, …

Member Avatar for mrnutty
0
459
Member Avatar for tennis

This : [code] class Test{ int i; public : Test() : i(0){} }; [/code] is very similar to this : [code] class Test{ int i; public: Test(){ i = 0; } }; [/code] The only difference is that the first one is more efficient, and as pointed out, its called …

Member Avatar for jonsca
0
105
Member Avatar for suzi_ausi

>>[B]const char *str1 = "pointer to constant"[/B] That means that the pointer points to a const data. Which means that the pointer can't change the const data that its pointing since a const data cant be changed. But it can point to somewhere else. >>[B]char *const str2 = "constant pointer";[/B] …

Member Avatar for Dave Sinkula
0
289
Member Avatar for DJPlayer

In C++ easy as 1,2,3 : [code] double toDouble(string str) //1 -- define function { //2 -- use simple logic and some stream object stringstreamm convert; convert << str; double val = 0.0; convert >> val; return val; //3 -- return value, assuming it was a success. } [/code]

Member Avatar for Dave Sinkula
0
226
Member Avatar for Audux

The use of destructor is to delete or release any memory that has been allocated. In Java, they handle the garbage collection for you. C++ is not as friendly. You have to use the destructor to delete or handle anything that needs to be handled when the object gets destroyed. …

Member Avatar for mrnutty
0
81
Member Avatar for RSBColt
Member Avatar for tennis

No since the return type is of char reference, that means you can change the value while accessing it as well.

Member Avatar for mrnutty
0
105
Member Avatar for mrnutty

[URL="http://www.codinghorror.com/blog/archives/000781.html"] This [/URL] is a little hard for me to believe. Thankfully, I am not one of those applicants, nor ever will be.

Member Avatar for vaultdweller123
0
1K
Member Avatar for eternaloptimist

>>[B] 1)if i wanted to write a line of code needed to declare a 1-dimensional array named names that can hold 8 string values would this be correct?: char names[8];[/B] Nope what you declared is an array of chars. chars are just 1 character. For example 'a' is a char, …

Member Avatar for eternaloptimist
0
107
Member Avatar for Skeen

>> the flamethrower works differently then the gun Does it? The flamethrower shoots and so does the gun. The flamethrower has some mass and so does the gun The flamethrower can run empty and so does the gun. The point here is that, they do differ internally, but not so …

Member Avatar for mrnutty
0
227
Member Avatar for soapyillusion

Make use of the string functions like find_first_of and so one. For example you can do something like this : [code] string vowels = "aeiou"; string sentence = "hello baby!"; if(sentence.find_first_of(vowels) != string::npos){ cout << "There is a vowel in " << sentence << endl; } [/code]

Member Avatar for soapyillusion
0
255
Member Avatar for Nick Evan

That sucks so bad. If it makes you feel better, my classes this semester is a tough load. Its busting my chops and we just started.

Member Avatar for apegram
0
295
Member Avatar for mybluehair

Just make a wrapper function : [code] void print(std::string msg, int posX, int posY, int color){ textout_ex(screen, font, msg.c_str(),posX, posY, color); } [/code] And use it like so : [code] void doo(){ string msg = "hello 2d world!"; print(msg,0,0,makecol(255,0,0)); } [/code] an even better wrapper : [code] void print(std::string msg, …

Member Avatar for mrnutty
0
108
Member Avatar for maddav

What you should do is create a 2D array class. Then use a vector to hold it. Here is what I mean : [code] std::vector< Array2D > vecOfArray2D; int size = 0; cin >> size; vecOfArray2D.resize(size); [/code] The Array2D is a class that you should implement.

Member Avatar for maddav
0
189
Member Avatar for WargRider

What you are looking for is template. I think this is what you are trying to accomplish. [code] template<typename Type> class Object{ protected: Type var; public: Object(){} Object(const Type& initValue) : var(initValue){ } virtual string toString()const ; //leaves the derived to implement this } [/code] Then you can do something …

Member Avatar for Narue
0
4K
Member Avatar for yakovm

Looks like your vertices are not correct. Have you tried to load a simple mesh first?

Member Avatar for mrnutty
0
207
Member Avatar for onaclov2000
Member Avatar for onaclov2000
0
92
Member Avatar for cwarn23

sigh. Its practically the same concept as before, when I gave you toHex() function. This time try to learn whats going on, please. [code] #include <iostream> #include <sstream> #include <string> using namespace std; template<typename Type> string toHex(const Type& value, bool showBase = true){ stringstream strm; if(showBase) strm << showbase; strm …

Member Avatar for mrnutty
0
185
Member Avatar for heredia21

Again use CODE TAGS...arghhh >>[B]What is the output?[/B] The output is either compile time errors, or a stack overflow in your "recurse" function.

Member Avatar for Salem
0
108
Member Avatar for nola_Coder

Show us how you are detecting your collision. And a picture of the situation would be nice as well. Depending on the situation, you might be able to get away with 1d collision.

Member Avatar for nola_Coder
0
94
Member Avatar for heredia21

Use CODE TAGS please? >>[B] What is the output? [/B] The output is a bunch of compiler errors, that says WTF are you doing?

Member Avatar for heredia21
0
70
Member Avatar for corby

First create a function that makes a rectangle like so : [code] ####### # # # # # # ####### [/code] After you get that , then its a simple change.

Member Avatar for corby
0
181
Member Avatar for mrackley86

You know most of the time the error says it all : [code]::list' : use of class template requires template argument list [/code] You have this [code] class MergingLists : public list[/code] The error tells you that list uses templates so that means that your MergingLists has to also be …

Member Avatar for mrnutty
0
181
Member Avatar for BinaryAssassin

It won't be hard. First if you do the way you suggested to do it, i.e [code] if(RIGHT_KEY_PRESSED) moveScreen(World.RIGHT); [/code] Then there will be a problem. The problem being that the screen will stutter. In fact try it out and see if its good enough, though. What I would suggest …

Member Avatar for BinaryAssassin
0
98
Member Avatar for OmarOthman

If you want to see if a/b == c/d , then all you have to check if a == c && b == d; More specifically, if a == kc && b == kd where k is an element from the natural numbers.

Member Avatar for WaltP
0
165
Member Avatar for spirit3ch

1) Your insert function is incorrect 2) Your remove function is mis informative, called it removeTop() or pop_front(). 3) You concat function shouldn't be very hard(unless I am missing something). All you have to do is either append the whole list you get into your list front part or the …

Member Avatar for spirit3ch
0
1K

The End.