Need help in UVA problem

basic-maths
uva

#1

This is link to my cide -> link to my code

Problem link (UVA 10106)

my code passing all the test cases(cases made by me as well) , but still on submission i am getting WA.

please see if you can figure it out what is wrong with the code , or any test case for which my code fails to print write answer.

thank you in advance.


#2

Your logic is correct, but your usage of feof() is not. According to this documentation, the EOF indicator is set after an attempt is made to read past the end-of-file. So your code sometimes does not detect the EOF and executes again on the last test case such as here. The correct way would be to check for EOF after a read operation, like this. This code gets accepted verdict.


#3

thanx man for the documentation.