Pergunta de entrevista da empresa think-cell

Write a function in C++ that implements a given functionality.