I want to really give,because i see my knowledge is not enough.
It would be nice ,if someone can add something to my code to make it work.I know it was close..
Line 13 and line 42. You declare the same output stream variable f2 twice.
The compiler is allowing this because the second declaration is in a separate scope (the body of the if statement is considered a separate scope).
However, both variables are attempting to open the same file as well. This is not allowed, and thus your second instance of f2 is not opened, and none of your code that writes to that instance of f2 will execute (since f2.is_open() is false).
To fix that issue, delete line 42. There's no reason for the second declaration of f2.
I don't know if the rest of your code will work properly at that point, but you should at least see some output. I give you credit for putting your code inside source tags, but your formatting is still horrendous and it's difficult to read the code. Clean up your formatting and it'll make it a lot easier for us to help debug your code.