Problem 1 in C++