To create a simple homemade microphone you need only a bunch of common electronic elements and a solder. Today I will present, how this microphone can be built at home.
How to sort numbers from STDIN
in programming, riddle / with 5 comments /
You get 10 numbers on STDIN, each followed by newline character, after that you have to display those numbers sorted from the smaller to the bigger. You cannot use sorting algorithms.
The riddle of the stolen wood
Sometimes piles of wood are marked by paint to protect them against thiefs. Continuous line is painted on the trees that are on the top of the pile, if one will steal some of them, then painted line on remaining stack will be discontinuous. To illustrate this tactic I made below picture:
If a thief would like to hide his crime, then what should he do? Present an algorithm to take n% of original trees and leave continuous red line on the remain pile.
3 x if
in C and C plus plus, programming, riddle / with 3 comments /
Below snippets in C check if foo() and bar() returns nonzero value and execute something() if needed. Are they equivalent? Why?
// first version if (foo() && bar()) { something(); }
// second version if (bar() && foo()) { something(); }
// third version if (foo()) { if (bar()) { something(); } }