Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Code that is written to the 2011 version of the C++ standard, sometimes known by its pre-publication name of "C++0x". Use in conjunction with the 'c++' tag.
4
votes
Implementing a proper linked list for a professional environment
Don't print error messages to cout, as that hurts reusability. I suggest changing the methods to return true on success and false on failure. The reason for the failure should be obvious enough to …
1
vote
Project Euler 14: Longest Collatz Sequence
Try adding the following:
#include <limits>
#include <sstream>
#include <stdexcept>
int main() {
constexpr unsigned max_odd = (std::numeric_limits<unsigned>::max() - 1) / 3;
…
for … {
…
3
votes
Implementing blockchain block in C++11
C++ code should be object-oriented. The make_block(…, …) and make_genesis_block() functions should be two-arg and no-arg constructors of the Block class.
6
votes
Morse code emitter
#include <sstream> is superfluous.
Morse is hard-coded to only emit its output to std::cout. It would be nice if cout were an overridable default.
Your treatment of '\n' is incorrect, in my opinion …
2
votes
URL Query params builder
You are not performing any percent encoding of parameter names or values, which would likely lead to breakage or even a security vulnerability if the you are given parameters that contain a special ch …
2
votes
Pairwise swap elements of a given linked list by changing links
Looking at just your pairwiseSwap() function… there are too many special cases.
Every iteration through the loop should verify that there are at least two more elements to process. You shouldn't nee …
4
votes
Array Dynamic resize in heap
The code is obviously wrong: your compiler should have warmed you that Resize() never uses its nSizeOld parameter.
8
votes
Accepted
Printing out a binary tree level by level
I got the following output:
Level 1: 5 Level 2: 2 8 Level 4: 4 7 10 Level 3: 1 3 6 9
Printing the layers in a non-deterministic order is probably undesirable behaviour. You used an u …
3
votes
Project Euler #4 - Largest Palindrome Product
n is an unused variable. Your compiler should have warned you about it (and you should compile with warnings enabled).
Declaring variables with auto and an unsigned integer literal is unconventional …
11
votes
Searching for pseudo-palindromes ("semordnilaps")
Preparing the vector of \$n\$ words takes \$O(n \log n)\$ time, because that is how long it takes to sort the words. Thereafter, each lookup takes \$O(\log n)\$ time for a binary search. (The times al …
3
votes
A partition algorithm for positive integers
Code organization
main() does everything. It would be a good idea to separate the concerns, such that main() is responsible for I/O and for calling a function that determines the optimal partition.
…
6
votes
Removing the largest values encountered so far in a list
Part of the problem is that you call max_element() twice.
If there are to be n elements in a list, of which d maxima are to be deleted, a naïve std::vector solution would take O(d n), with the time b …
17
votes
If she floats then she is not a witch like we thought
Bugs
You calculate the volume of the sphere incorrectly!
Style
You misspelled the variable bouyantForce.
The constant waterBuoyancy is a misnomer. It should be waterDensity.
There's not much poin …
6
votes
Computing factorials
You should separate the computation code from the input/output code. As you have written it, the factorial computation code will never be reusable in any other program. To be specific, you should defi …
6
votes
What's in your file?
You use C++-style input/output, but your design is fundamentally C.
An idiomatic C++ solution would have a smart class rather than a dumb struct. Something like
class FileStats {
public:
File …