There are a couple of things you need to understand here:
1) C and C++ are very different languages - C is ancient history and C++ is a superset of C. That means that C++ code works in a very different way to C code, and contains all sorts of concepts that aren't available at all in C. It's like saying "a Model T Ford is a Car, and so is a Tesla Model S, so the engine from the Tesla will fit perfectly into the Ford with no effort whatsoever".
Obviously, it won't: the two are so far apart in time that they don't share a single component, or even many concepts beyond "personal transportation with four wheels".
It's probably possible to do it - and I'm sure some lunatic will try the Tesla / Ford hybrid - but it'll involve a lot of effort and what you get in the end isn't going to be any good as either of them.
Converting C++ to C is the same deal: well written C++ doesn't translate into well written C for the same reasons: C has no concept of classes, of vectors, streams, strings, or pretty much anything other than the basic "four wheels" idea.
And now we come to the code you want to translate - and that isn't good C++, it's somebody's homework and while I'm sure they were proud of it when they handed it in, it's pretty clear that they had little idea what they were doing.
2) Homework is set for a reason, and it's not to annoy you! The idea is that coding is a skill, a mindset, and you need experience to learn how to do it. Just like when you were learning to ride a bike you can't just jump on and zoom off into the distance because you don't have the reflexes built up to keep you and the bike upright and until you develop those, you will fall over a lot. Software is the same: if you don't write it yourself, you never learn how to write it - and that means that the next exercise (which will be built on what you learned from this one) will be much harder for you because you don't learn by looking at code andy more than you learn to ride a bike by watching the Tour de France!
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help:
How to Write Code to Solve a Problem, A Beginner's Guide[
^]
Will it translate? Yes. If you know both languages, it's a fairly trivial job with that badly written chunk. Is it a good idea to do it? No. So stop trying to cheat your homework, and give it a try - it's a simple enough task that it shouldn't take you long at all and it'll make your life a whole lot easier in thw future!