can someone tell me what should I write in the loop.I could not do that. I have tried to use for and if,but nothing.I think I wrote them wrong.
Assume the event, tasks, and number of days information for a given project are stored in a file called project.dat. A sample set of data might be:
Event Task Number of Days
1 a 3
1 b 5
1 f 2
2 a 7
2 b 4
3 a 1
3 b 2
3 c 3
Write a C++ program that reads the critical path information and lists in an output file called timetable.txt each event, the number of tasks in the event, and the number of days required to complete the event.
The program should also write to the output file the total number of events and the total number of days for the project completion.
Thanks. So when you read an event, you need to know if you've seen it before. That suggests a set of events. The set can tell you how many events there are with set::size(). You will also need to track the total number of days. So here is some pseudocode:
1 2 3 4 5 6 7 8 9 10 11 12
set<unsigned> events;
unsigned totalDays = 0;
unsigned event;
string task;
unsigned days;
...
while (cin >> event >> task >> days) {
events.insert(event); // this will ensure that the event is in the set.
totalDays += days;
}
// print the totals.