Hello. I can write this code for you. You did not stated in which language it should be done, I see from tags that it's Java or C++, I can do both. Also, can you share more details like do you need UI or simple console task? For c++ are arrays dynamic or fixed?