Can anyone please solve this and send me the code?
If you look in each of the language specific forums, you’ll find a solution to Test, for example C++, Pascal or Java, and there are others.
Can solve this in c++?
Yes, follow the link.