Posts
 
Reputation
Joined
Last Seen
Ranked #129
Strength to Increase Rep
+10
Strength to Decrease Rep
-2
93% Quality Score
Upvotes Received
211
Posts with Upvotes
151
Upvoting Members
73
Downvotes Received
10
Posts with Downvotes
9
Downvoting Members
9
47 Commented Posts
7 Endorsements
Ranked #260
Ranked #191
~182.26K People Reached
About Me

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

388 Posted Topics

Member Avatar for JoBe

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

Member Avatar for Alfonso_4
0
876
Member Avatar for montjoile
Member Avatar for Tushar_4
0
2K
Member Avatar for kylcrow

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

Member Avatar for zia shaikh
0
5K
Member Avatar for Dave Sinkula

Thank-you Andrew Koenig and Barbara Moo..I appreciated yours words of wisdom. You're welcome.

Member Avatar for shahidali6
11
10K
Member Avatar for nightcrew

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 …

Member Avatar for omgerg
0
3K
Member Avatar for biljith

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?

Member Avatar for ReaseySo
0
271
Member Avatar for bob89

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 …

Member Avatar for paladin.lone
0
338
Member Avatar for crazyboy
Member Avatar for Kirielson

[code]ofstream f(filename, ios_base::out | ios_base::app);[/code] iosbase::app means that you want to append to the file.

Member Avatar for ankit1990rana
0
8K
Member Avatar for blee93

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 …

Member Avatar for vCillusion
0
367
Member Avatar for rena0514

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.

Member Avatar for guly2010
0
4K
Member Avatar for predator78

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

Member Avatar for mike_2000_17
2
734
Member Avatar for Geli19

Also: Why are you writing `DataType *Ptr = new DataType();` instead of simply writing `DataType Obj;` ?

Member Avatar for Geli19
0
5K
Member Avatar for silvercats

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.

Member Avatar for arkoenig
0
356
Member Avatar for henry.sj.shin

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])

Member Avatar for TrustyTony
0
394
Member Avatar for Microno

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 …

Member Avatar for ravenous
0
175
Member Avatar for DonutsnCode

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 …

Member Avatar for elmohler
0
940
Member Avatar for gerard4143

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.

Member Avatar for gerard4143
0
368
Member Avatar for SoulMazer

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 …

Member Avatar for saravmittar
0
197
Member Avatar for misalazeem

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 …

Member Avatar for arkoenig
0
2K
Member Avatar for iamthesgt

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.

Member Avatar for markshah2
0
631
Member Avatar for optimumph

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

Member Avatar for mzimmers
0
228
Member Avatar for eRayven38

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.

Member Avatar for deepu.sri24
0
1K
Member Avatar for sergent

What would you do with variable-length arrays that you can't do better with C++ vectors?

Member Avatar for mike_2000_17
0
219
Member Avatar for programing

I think this question would be better asked in the C forum, as the program you posted has no significant C++ content.

Member Avatar for trin12345
0
178
Member Avatar for hujiba

Remove the call to srand from the choose_number function. As a general rule, you should call srand only once in your entire program.

Member Avatar for doug65536
0
170
Member Avatar for Labdabeta

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 …

Member Avatar for murnesty
0
100
Member Avatar for Pikachumanson
Member Avatar for Kyren5058

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?

Member Avatar for cherrymae.calma
0
282
Member Avatar for frogboy77

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

Member Avatar for pseudorandom21
0
426
Member Avatar for aomas98

The problem is that the OP doesn't know how to solve this particular problem, and wants someone else to do it instead.

Member Avatar for Rashakil Fol
-2
177
Member Avatar for reallyslick
Member Avatar for drdaco

I hate to sound smug, but this is not a difficult problem. In effect, you have a string of 0's and 1's that you want to treat as a binary number, and you want to add 1 to it repeatedly. Adding 1 to a binary number is easy: Take all …

Member Avatar for Adak
0
251
Member Avatar for reallyslick

What happens if you include <string> before you include Profiles.h? If that doesn't solve the problem, can you tell us which line(s) the compiler reports as erroneous?

Member Avatar for ztdep
0
814
Member Avatar for afi@alvi

Use the [I]next_permutation[/I] algorithm that's part of the C++ standard library.

Member Avatar for arkoenig
0
108
Member Avatar for DJSAN10

The results are undefined, which means that a program that does so is permitted to do anything at all.

Member Avatar for DJSAN10
0
670
Member Avatar for tiredoy

If you can figure out what the code means, then I suggest you take an example that someone else has written that uses inheritance and try to rewrite it into a program that behaves the same way but does not use inheritance.

Member Avatar for mike_2000_17
0
233
Member Avatar for zentechsupport

Please post your entire program, using code tags, and tell us what is happening that you don't expect.

Member Avatar for woooee
0
264
Member Avatar for L0s3r

Both of your examples are wrong: A function must never return a reference to a local variable. Whatever output such a program produces is the result of coincidence and cannot be trusted.

Member Avatar for arkoenig
0
92
Member Avatar for rachelir

The reason is that DictionaryList (defined on line 7) and dictionaryList (used on line 11) are different types.

Member Avatar for arkoenig
0
206
Member Avatar for clickspiker23

What happens if you change ... << setprecision(2) << ... to ... << fixed << setprecision(2) << ... ?

Member Avatar for clickspiker23
0
147
Member Avatar for bandrei2408

You say: "The problem asks to create a program with the complexity O(n) and i wonder if the program i made is a O(n) complexity." A program with complexity O(n) that does what?

Member Avatar for bandrei2408
0
146
Member Avatar for Vinod Supnekar

[QUOTE=Vinod Supnekar;1580467]Now if i use [CODE] #include <stdio.h> main() { int c; while ((c=getchar()!=EOF)//get the sinle char putchar(c);//prnt it on cmd } [/CODE] [/QUOTE] then your program will not compile because of the unbalanced parentheses in line 5.

Member Avatar for Ancient Dragon
0
444
Member Avatar for dotancohen

IIRC, if a function that is declared to return a value falls off the end without doing so, the C89 standard permits this state of affairs so long as the caller does not try to use the value that the function failed to return. In other words: [CODE] int foo() …

Member Avatar for vegaseat
0
200
Member Avatar for F.O.G
Member Avatar for kandarpa

If allocating and initializing dynamic memory is a significant part of your program's overall execution time, you may want to reconsider your design. My reason for saying this is that if initialization is significant, it suggests that you're not doing much else with the memory aside from initializing it. In …

Member Avatar for N1GHTS
0
3K
Member Avatar for trantran

You say "2 different objects share the same memory location if their content are identical." The thing is: If they share the same memory location, they are not different objects.

Member Avatar for trantran
0
193
Member Avatar for steve421
Member Avatar for senthilamp4

It is hard to know whether a change to your program will make it faster until you understand where it is spending its time now. For example, if the program is slow because the operating system's file system is taking too long to open and close all those files, adding …

Member Avatar for senthilamp4
0
165
Member Avatar for dgreene1210

What you've written is really a C program. I suggest that you either rewrite it in C++ or ask your question in the C forum. Also, please use code tags.

Member Avatar for MareoRaft
0
974

The End.