C++ だけとクラスとか定義してないから入出力を書き換えればC言語にできるんじゃね?
http://apollon.issp.u-tokyo.ac.jp/~watanabe/int/ten.html