updated cpp solution problem #15