- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 211
- Posts with Upvotes
- 151
- Upvoting Members
- 73
- Downvotes Received
- 10
- Posts with Downvotes
- 9
- Downvoting Members
- 9
Mostly retired computer scientist after 26 years at Bell Labs and its offshoots. Founding member of C++ standards committee. Project editor for the 1998 and 2003 versions of the C++ standard. Author of "C Traps and Pitfalls" and coauthor of…
- Interests
- Most of my energy these days goes into music and photography.
- PC Specs
- Core 2 Extreme Q6850 (quad core), 3 GHz/3.25 GB RAM; Windows XP SP3.
Re: [QUOTE=JoBe;188512]Ok, thanks for the additional info :!: I think I could do this by putting an if statement in it, for example when the while loop is at N°3 it should enter 0 into the vector, this way the amount of vectors is correct, but the total amount isn't.[/QUOTE] The … | |
Re: How about explaining what you expect the statement to do? It looks like nonsense to me. | |
Re: [QUOTE=Ancient Dragon;1501019]Nice info, but 4 years too late.[/QUOTE] And wrong, too, for at least two reasons that come to mind immediately. | |
Re: Thank-you Andrew Koenig and Barbara Moo..I appreciated yours words of wisdom. You're welcome. | |
Re: If there's no upper bound on n, then you need a data structure that can grow without bound. If you can't use arrays or pointers, then you must find some other data structure that grows without bound. If you're not allowed to use any such data structure, then the only … | |
Re: And now that it's in the C++ forum, I can point out that the title of this thread talks about printing the reverse of a number, but the program computes the sum of its (decimal) digits. Which is right? | |
Re: Is there a reason that you are insisting on an AVL tree rather than just a data structure that will use an order relation to store values in a way that will keep equals together? Because if you just need the latter, you should be able to get std::set (or … | |
Re: [code]ofstream f(filename, ios_base::out | ios_base::app);[/code] iosbase::app means that you want to append to the file. | |
Re: Not every C++ implementation is capable of supporting an integer as large as 600851475143. So if you want to use a C++ implementation that doesn't support integers that large, you have a few choices: 1) Figure out how to represent such large integers for yourself. 2) Find an extended-precision integer … | |
Re: What do lines 20-22 do? They don't seem to correspond to any part of the problem specification. In particular, they seem to say that A(0,1) is equal to A(1,1). I see no justification for that claim. | |
Re: [QUOTE=Ancient Dragon;1572886]The republicans had no say in passage of Obamacare. The Democrats controlled both houses of congress at that time. So I don't know how you can possibly blaim the republicans for anything.[/QUOTE] That's easy: the same way that the original poster can talk (apparently with a straight face) about … | |
Re: Also: Why are you writing `DataType *Ptr = new DataType();` instead of simply writing `DataType Obj;` ? | |
Re: To Silvercats: Everything in Accelerated C++ is as valid now as it was in 2000. It is true that it doesn't cover the C++11 stuff, but it is possible to learn that stuff later. | |
Re: I think that you probably have something like this in mind: def print_reverse(s): for i in range(len(s)-1, -1, -1): print(s[i]) | |
Re: I doubt you're going to find anyone to help you with this code because your description of what it's supposed to do is so unclear. To begin, (x^2+x)/(x^2+x^3) isn't a polynomial; so your claim that your program finds the integral of a polynomial is not correct. Therefore, we don't actually … | |
Re: The paragraph you cite is an example of explaining how to avoid a bad programming technique by using a second bad programming technique. Here's why I say that. A reference is an alternative name for an object. For example, if I write [code]int i; int& j = i;[/code] then I … | |
Re: I would think that if you replace the type std::pair<std::string, unsigned long> in lines 7 and 23 by std::pair<const std::string, unsigned long>, it ought to work. At least I can't think immediately of any reason it shouldn't. | |
Re: This code doesn't work: [code] std::list<bullet> bullet_list; std::list<bullet>::iterator iter; bool alive = false; for (iter = bullet_list.begin(); iter != bullet_list.end(); ++iter) { bool isalive = iter->alive; if (isalive == true) { alive = iter->move(); // move is a function inside the struct "bullet" } if (alive == false) { int … | |
Re: There are four conditions that must be met for checkmate to occur: 1) The king is in check. 2) There is no move that the king can make that takes it out of check. 3) It is not possible to capture the attacking piece. 4) It is not possible to … | |
Re: I don't even need to ask how your program is supposed to work because it can't -- there is no way for recursivecandy to return that does not involve a recursive call, so there is no way for it ever to return a meaningful value. | |
Re: [QUOTE=mzimmers;1691543]Everything you say makes sense. I just found it odd that an algorithm that needs to be told the start and the end of the data (like sort) would expect the end to be beyond the final valid element. But, your position is supported by the results of the program, … | |
Re: I don't understand the assignment. Deleting an element from a doubly linked list is not inherently an iterative operation, which means that there is no obvious way to transform it into a recursive operation. | |
Re: What would you do with variable-length arrays that you can't do better with C++ vectors? | |
Re: I think this question would be better asked in the C forum, as the program you posted has no significant C++ content. | |
Re: Remove the call to srand from the choose_number function. As a general rule, you should call srand only once in your entire program. | |
Re: Xoring the bits of an integer is equivalent to computing its parity. There are ways of doing so that might be faster than your original example, but you'd have to measure to see whether it's really faster in practice. The way that comes to mind is this: Divide the integer … | |
Re: Isn't that the subject matter of your course? | |
Re: Here are some questions for you to answer? 1) Do you know how to print the first line of the required output? 2) Do you know how to print the second line? 3) If I give you a number n, do you know how to print the nth line? | |
Re: [QUOTE]Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is … |