Solution to 1.2 in Java and C

Signed-off-by: Tomasz Kamiński <kaminski.tomasz.a@gmail.com>