Hey guys, i'm studying files in C and when i do the following assignment, I get stuck.
Problem: There are N boxes(1 ≤ N ≤ 1000). Each box has its own capacityCi (1 ≤ Ci ≤ 10000, 1 ≤ i ≤ N). Boxes are used to carry water from far away. Given the amount of water in each box. Calculate the minimum number of boxes needed to carry.
Input: from file WATER.INP with structure:
- the first line gives N (number of boxes)
- the following N lines, each line has 2 parameters: Bi and Ci (0<= Bi <= Ci) which is th information of the i th box (Bi is amount of water, Ci is the capacity).There is at least one space between Bi and Ci.
Output: create a file WATER.OUT that contains the minimum number of boxes needed.
For examle:
WATER.INP
4
0 1
4 5
0 2
1 2
WATER.OUT
1
I know how to print down a text file to screen, but not the files contains numbers. And I don't know how to access to each number in that file to use for my program.
Hope you guys can help.
Many thanks.