Merge C++ and Java versions
Add main.cpp