It's a bad habit to create variables at the beginning of loops like you do on Line 29. I honestly can't read this because of how you have your variables named. You would be doing yourself a great service if you just did a simple find and replace (Ctrl + R in Code::Blocks) to update the names to something that makes sense for their context.
Probably a good idea to clean up your code and put in comments before posting it here, especially if you use temp5 - temp8 which means nothing to anyone but you. I also recommend to describe what the program is doing or supposed to do.
You define double temp5; twice.
I don't understand what temp.tag is, you didn't show any examples of input and it doesn't appear to be defined.