- 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.
Hello ladies and gents, Chapter 3 exercise 3-1: [quote]Suppose we wish to find the median of a collection of values. Assume that the we have read some values so far, and that we have no idea how many values remain to be read. Prove that we cannot afford to discard … |
|
hi there, I'm coding in windows, c++, but when I traslate my code to ubuntu, g++, I get this error: [B]lvalue required as left operand of assigment[/B] This is the line where I get the error: [COLOR="Red"][/COLOR][CODE]&*raiz=&*p;[/CODE] What could be the problem? *raiz and *p are pointers to an avl … |
|
Hi. I am new to the forum and I had a question. I have looked around and haven't really been able to find exactly what I am looking for. I am looking for the code in C++ to read in a random single line with spaces from a file. This … |
|
With regard to C++ books, I'll just echo the advice here .The following books are recommended; read them in mostly the order listed." Accelerated C++ " Andrew Koenig & Barbara Moo " The C++ Standard Library " Nicolai Josuttis --- a "must have" " Effective C++ ", " More Effective … |
|
[QUOTE]Assume you have a int variable n that has already been declared and initialized. Its value is the number of integers that need to be read in from standard input and printed out in sorted (ascending) order, each on a line by itself. Furthermore, there are no duplicates in the … |
|
isnt this the shortest method [code=c]#include<iostream.h> #include<conio.h> void main() { clrscr(); int a,i=0; cout<<"enter a number"; cin>>a; while(a>0) { int b=a%10; a=a/10; i=i+b; } cout<<"sum="<<i; getch(); }[/code] |
|
I know that there are plenty of open source implemenations of AVL trees out there but I was wondering if it is possible to have a AVL that has repeat entries. I want to use one so I can search records by various fields. Eg I would have one for … |
|
Invalid sequence in stack permutation ???? inpurt sequence ... 1 2 3 4 5 1) 4 3 5 2 1 2) 2 3 5 4 1 3) 5 4 3 2 1 4) 3 4 1 5 2 Answer is .... 4) ..... but i dont know how ? can … |
|
In C++ it seems like every single time you open a file, the inner contents get deleted quickly. Is there a way to open the file at the end of the last character while keeping all contents within the file? I've been looking at something with the End of file … |
|
I am doing Project Euler Problem 3, but I seem to get stuck. I have written some code that makes sense (at least to me) but keeps printing the answer to 137. This is the problem: The prime factors of 13195 are 5, 7, 13 and 29. What is the … |
|
Ackermann's function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Write a function A(m,n) that solves Ackermann's function. Use the following logic in your function: If m=0 then return n+1 If n=0 then return A(m-1,1) Otherwise, return A(m-1, A(m, n-1)) Test … |
|
I'm hoping this will stir the pot a bit lol. But in all seriousness if you could get rid of the "need for greed" and "status", and yet not cross to many boundries. Don't you think that this could provide a more reasonable standard of living for everybody? My main … |
|
Hello Everyone. I am having trouble creating new objects in a loop. I am using: DataType *Ptr = new DataType (); I use this in the beggining of the loop then end the loop with: delete Ptr; Each constructor and destructor gets called each time the loop is executed.... but … |
|
with questions at the end. coding exercises and answers. for extreme beginners. |
|
Hello All, I'm trying to write a function that outputs the reverse of the input. I know that you can use the built-in list.reverse() or S[::-1] methods, but I want to make it using the 'for' loop. My code initially is: def reverse(S) for x in S: print(x, end = … |
|
A while back i wanted to develop an application that calculated the integral of any polynomial that was input but I felt it was lacking the capability to to find more complex polynomials such as: > (x^2+x)/(x^2+x^3) Unfortunately my attempts at implementing a numerator and denominator as part of the … |
|
Hi guys, Your typical C++ beginner here. I'm using the renowned Deitel C++: How to program to learn C++. I am my own mentor and here's what I can't comprehend: What's a Dangling Reference? According to Deitel C++: How to Program and I quote "Functions can return references, but this … |
|
Is it possible to pass a map container to the copy algorithm and display it to the std::cout? If so how? What I tried below doesn't work but it looks like it should. Any comments or pointers will be appreciated. [code] #include <iostream> #include <string> #include <map> #include <algorithm> #include … |
|
Hi, I'm a beginner to C++ and am having some trouble with my list. I first define a struct named "bullet' like so: [code=c++]struct bullet { bool alive; bullet() alive = true; };[/code] Then, I create a list of objects of type "bullet": [icode]list<bullet> bullet_list;[/icode] In my program, I frequently … |
|
Hello Everyone, I am writing chess code in C++ using a main cpp file and functions only.. SO basically am done with everything except the checkmate condition... the only conditions for checkmate i have checked are the movements that king can make.. but there might be other possibilities of saving … |
|
This is another homework problem. I thought it was easier, and I wouldn't need help, but I keep getting a segmentation fault when running the program. The assignment is to use a recursive function to output the amount of candybars we can buy with a user-inputted amount of money. Each … |
|
I'm trying to sort an array of numbers in ascending order and don't know whats wrong with my code (I'm completely new to vectors). I should first copy the input array (data) into an STL vector, then apply STL’s sorting algorithm to the vector, and finally copy the vector back … |
|
Hey Guys, I am really trying to get into List-Implementation. Everything I wrote works fine except the "delete Element at Position" funktion. With the iterative Implementation there is no problem, everything works, but I want to do a recursive Version. This is the Task: Invent an algorithm which becomes a … |
|
I don't get why ISO don't include VLAs in C++ standard. C++ is supposed to be a C extension, and C99 clearly supports VLAs. It is not hard to implement and does not break any existing C++ code. It is useful for beginners, who do not yet know pointers, and … |
|
hi my program should implement queue using stack h make a code but i still have error if an one can tell me what is he error [CODE]#include<stdio.h> #include<conio.h> #include<process.h> int in_top=-1; int out_top=-1; void in_stack_push(int item); int in_stack_pop(); void out_stack_push(); int out_stack_pop(); int insert_queue[20],delete_queue[20]; void main() { int i,ch,item; … |
|
I'm new at this so sorry if my vocabulary and stuff is totally off. With the following syntax, my goal is to call the choose_number function, which, when given two arguments (integers), returns one of those two at random. I run it multiple times with a for loop but it … |
|
Quick question (though I still want to get my long OpenGL question fixed) is there a faster way to Xor the bits of an integer than this: [CODE](MyInt&0x1)^((MyInt&0x2)>>1)^((MyInt&0x4)>>2)//etcetera[/CODE] Just to clarify by faster I mean faster to execute, not to type as this operation will have to be done many … |
|
Ok I have an assignment for school where we are building a compiler step by step each week. This week I have to make a syntax analyzer that picks out the errors from this text file below. In the source code I have provided below I have a lexical analyzer … |
|
Hi there, right now my teacher wants me to make an outline of a half-diamond with numbers, using for loops, kind of like the following: [code] 1 2 3 4 5 4 3 2 1[/code] The number 5 is a user input, so the half-diamond's width would be controlled by … |
|
English rioting for no apparent political reason, more a case of get what you can while the going is good. Does it get much worse than [URL="http://www.bbc.co.uk/news/magazine-14487982"]this[/URL]? Is society really broken? |