btw, @Corbin - the main idea was to provide a
puzzle to OP - since he asked "how we can spot the difference in the 'level' of a coder", I've done this one in a couple of ways, firstly and foremostly by providing a version that only fixed his most obvious errors (without changing the actual code's behaviour), and later by creating this one, portable to C++ by only the simplest printf/scanf -> cout/cin substitutions... it was meant to be a
puzzle, not a definite answer to the problem (it's not
stackoverflow but
codereview after all) —
vaxquis 6 hours ago