step 1 : pick a language.
step 2 : write logic to open and read a file.
step 3 : write logic to parse the data read from the file
step 4 : write logic to solve the problem from data parsed
step 5 : write logic to output results
Four of those steps involve writing logic and YOU need to do that. It's not our homework.
Here's a tip : since you listed C first, here's documentation for
fgets - at C++ Reference[
^] and that page includes sample code to open a file, read a line from it with fgets, and close the file. That will be a good start for you.