2,712 Posted Topics
Re: 1)Draw the top border 2)Draw the first '*' and follow it up with space 3)Repeat 2 until end 4) Draw the bottom border Maybe this will help : [code] void drawB() { const int C = 4; const int R = 4; for(int i = 0; i < R; i++) … | |
Re: Well the point is to learn how to code function and not learn how to use the java library. Although later on you will almost always. Here is some psuedo code that might help: [code] Function max(a,b,c) max(a,b)->x return max(c,x) End Function Function min(a,b,c) min(a,b)->x return min(c,x) End Function Function … | |
Re: I'm not sure what you mean, post example of what you have and possibly what you are trying to achieve. | |
Re: Why are you using anonymous functions? Its very unclear. Also your start action listener is wrong I think. It goes into an infinite loop. | |
Re: As of right now, C++ does not allow you to separate template header and its definition. You need to put the template definition in the same file as the header. | |
Re: How about you give it a try and we'll be here to guide you. | |
Re: So the easiest thing for you todo is make this into classes. I'm guess you don't know about classes that much. So the next best thing you can do is make this into functions. Here is a brief skeleton. [code] //#include everything int main(){ const int MAX_COLORS_TO_GUESS = 4; string … | |
Re: You don't call Accumulate anywhere. Call it inside your constructor. | |
Re: My guess is that you need to override [I]indexOf(Object obj);[/I] Post your code including the imports. | |
Re: The only way that loop terminates is if [i]result = true and current.getNext() = null[/i]. What you want is the binary AND logical operation not the binary OR logical operation. Also there is no need for [i]line 10[/i]. result will stay false unless it is true, and if it is … | |
Re: You guys see it as bad coding, while I see it as an art of stupid. | |
Re: If you do not go towards the better solution of using the above links, then what you want is to use an array. Work by digit by digit. | |
Re: This sounds like an h.w or an exercise, so doing this : [code] std::sort( name, name + SIZE ); int pos = std::binary_search(name, name +SIZE, "JOSH"); [/code] would not be beneficial. And as pointer out, the string class overloads the relational operators, so that means all you have to do … | |
Re: umm, haven't done opengl for a while, but I think you are looking for [B]gluPerspective(..)[/B]. Its areguments are the following [code] void gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); [/code] So just specifiz zNear to be some negative number and zFar to be an adequate high number and … | |
Re: I always find myself using the template pattern. The decorator pattern is pretty elegant. Just some thought, visitor pattern is rarely used, at least for me. And usually, unless its the rare case, using Singleton Pattern is not the answer. Factory patterns are ok. They're nothing unusual. But for the … | |
Re: Psuedo-Code [code] for i = 1 To N if(N % i == 0) printFactor(i); [/code] | |
Re: [URL="http://en.wikipedia.org/wiki/Euclidean_algorithm"]http://en.wikipedia.org/wiki/Euclidean_algorithm[/URL] | |
Re: [QUOTE=Clinton Portis;1052806]For most assignments of this nature, most go with storing user input into a cstring.. then use a loop to display the contents of the string in reverse order. Simple. Straight-forward.[/QUOTE] I think he means something like this : [code] Enter 10 numbers : 10 9 8 7 6 … | |
Re: >>[B]empnum(0,"","",0.0);[/B] remove that | |
Re: [QUOTE=Hayzam_#include;1391052]hi I wonder who is the smallest boy to know any low level programming language Eg:C++ or java etc exept the qbasic[/QUOTE] Wow that might be the most non-intellectual question I have read on this forum. You should get a prize or a cookie. | |
[B]Problem statement:[/B] Give two sets [TEX]A[/TEX] and [TEX]B[/TEX], devise and algorithm that checks if A and B are [URL="http://en.wikipedia.org/wiki/Disjoint_sets"]disjoint[/URL]. The following information are given about the set [TEX]A[/TEX] and [TEX]B[/TEX]: [LIST=1] [*][TEX]|A| = |B| = n[/TEX], that is number of elements in both sets are n [*]A and B are … | |
Re: It makes sense. To help you better, you should post some source. | |
Re: ummm, not sure why but how about this idea: [code] struct EmptyType{} template<typename T1,typename T2 = EmptyType(),...and so on for some finite amount> struct TupleType{ typedef type1 T1; typedef type2 T2; //...and so on } int main(){ Tuple<int,bool,char,string> Tuple::type1 intType = 0; Tuple::type2 boolType = false; //... } [/code] What … | |
Re: @OP: Why would you want to do that? | |
Re: Make the [i] make_thirds[/i] either a static function or a standalone function. | |
Re: I think you need to look at your design again. For some reason what you are doing doesn't seem like a good way to go about it. I would suggest an alternative but, I'm not completely sure how your code works. | |
Re: >>[B]Secondly the program is well structured, but only one class??? [/B] I beg to differ. Its hard to read. Global variables, overly complicated, and definitely not well structured. | |
Re: Before resorting to inheritance, can you state your actual problem with some actual context? Maybe you have been going about this problem wrong? | |
Re: almost, e = 1/0! + 1/1!... so you have to add 1/0! = 1 to each output. [URL="http://upload.wikimedia.org/math/a/1/0/a10a05335ccb3b560a678ed2dd287fdb.png"]taylor series representation of the constant e[/URL] | |
Re: [CODE]George Bush 70 77 Barack Obama 70 75 80 Bill Clinton 68 70[/CODE] Does the general format goes like so : [code] FirstName LastName score1 score2 ... scoreN [/code] or are there only score1 and score2 for all names? Either way you should do something like so : [code] struct … | |
Re: change this [icode]calculation function_one(calculation addition)[/icode] to this [icode]calculation function_one(calculation& addition)[/icode] and realize the difference. | |
Re: If you want that then you need to have a fraction class that handles that. So that instead of just displaying its floating values, it can display the numerator and denominator. Thus ultimately, you need to keep a variable for the numerator and denominator. So instead of [icode]double re,im[/icode] you … | |
Re: Ex: Absolute position: [icode]monster.setPosition(100,100); [/icode] Relative position: [icode]hero.setPosition(monster.getX()+100,monster.getY()+100)[/icode] So in the absolute position, the monster in place in an absolute position at (100,100), while the hero is placed relative to the monster, that is the hero is placed 100 plus the monster x position and 100 units plus the monster … | |
Re: Take for example the call result(3). Trace the recursion out and get: result(3) = result(2)*2 = result(1)*2 * 2 = 2*2*2 = 8 So you see calling result(3) calls result(2) which calls result(1). Thus there are 3 calls to result n. If you try to generalize it, you will see … | |
Re: [code] string Direction = "i"; [COLOR="Red"]cin>>Direction;[/COLOR] [COLOR="red"]while((Direction != "L")||(Direction != "l"))[/COLOR] [/code] Make similar changes. Use Direction as an string object, not as a string array. | |
Re: @OP: Forget you ever saw that code. Its useless.This [iCODE]insertion-sort_recur(a, n-1);//how does this line work[/iCODE] acts like a for loop. It keeps going until it reaches the second element. Then it returns to the third element. Then to the fourth and so on... | |
Re: What exactly do you need help with? Maybe a kick start would help. Here is some ideas: [code] class Cash{ private: int money[10]; public: enum {PENNIES,NICKELS,DIMES,QUARTERS, ONE_DOLLAR,FIVE_DOLLAR,TEN_DOLLAR,FIFTY_DOLLAR,ONE_HUNDRED_DOLLAR public: Cash(){ for(int i = 0; i < 10; ++i) money[i] = 0; } void add(const Cash& money){/*Add code here*/} void subtract(const Cash& … | |
Re: make initCheck a static method. Do you know what the term static mean in the context of programming? | |
Re: [img]http://upload.wikimedia.org/math/e/7/2/e72a9c97103eed0fe72a1975a8fd748a.png[/img] [TEX]sin(x) = x - x^3/3! + x^5/5! - x^7/7!...[/TEX] In C++ terms : [icode] //approximates in 3 expansions float sinus(float x){ return x - (x*x*x)/(3*2*1) + (x*x*x*x*x)/(5*4*3*2*1); } [/icode] Of course you can use a for loop and a factorial function and a power function to expand it more, … | |
Re: @FBody: I don't think thats the problem, because he uses end just like you did in your for loop, for comparisons. And in the line he was pointing to, it definitely shouldn't have a bad pointer exception, if his code were working. @OP: Can you show us that HList is? … | |
Re: Create a class to hold data's: [code] class PersonInfo { private: std::string name; std::string nationality; char gender; // and so on public: //some methods to get datas , set datas and any other function //that you think will be sufficient to this class usually goes here. }; [/code] Now create … | |
Re: Couple of ways, one way is to do the following : [code] //interface struct Conditional{ virtual bool preCondition()const=0; virtual bool postCondition()const=0; }; //adapter for default struct ConditionalTrueAdapter: Conditional{ bool preCondition()const{return true;} bool postCondition()const{return true;} }; //interface struct Command{ virtual void execute()=0; }; class PauseGameCommand : public Command{ private: Conditional condition; … | |
Re: Post the ascii art one more time, but this time wrap it under code tags. It looks like your binary search tree does not satisfy the property that all left subtree are smaller than the parent, and all right subtree are greater than the parent. | |
Re: A popular way to handle large matrix is to divide the matrix into multiple chunks and work that way. Try to see if thats possible. Or post the actual problem here and surely someone can help you figure out a proper solution. | |
Re: try putting [icode]void stringcomp(string str);[/icode] right before "int main()". Also I hope you got a "stringrec.h" that has the prototype of the functions defined in "stringrec.cpp" | |
Re: Instead of this [icode]float f1,f2,f3,f4;[/icode] use an array like so [icode] float point4[4][/icode]. There are more benefits to use an array than 4 different variables. Plus its easier to maintain. | |
Re: The code [icode] FLATMATE resident; [/icode] creates an instance of FLATMATE. It is called an object. Whenever you create a DUTY object, inside that duty object, is an instance of FLATMATE. So each DUTY object has a FLATMATE object. Its similar to this: [code] class DUTY{ int resident; } [/code] … | |
Re: how about you give it a go, and see what happens. Try your best first. Think about this in small steps. | |
Re: I don't like your consistency with your naming conventions. Don't abbreviate it. Just name your variable something that we all can understand. For example, instead of [i]BST(bull shit tree?)[/i] call it BinarySearchTree. So as to your program, in no particular oder: 1) You need to abstract your program more. Define … |
The End.