A critical task analysis

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.
We need more information. Can events run in parallel? What about tasks within an event? What would the output be for the sample you've given?

Can you describe how you would solve this by hand? Sometimes that helps to figure out how to do it in code.
Event number of tasks number of days
1 3 10
3 2 11
3 3 6


Total number of events 3
Total number of days 27


this is the output..this is the whole question.

in hand.I write.
if (event ==1)
then add number of days..but it did not work..all variable are declare.
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. 
Topic archived. No new replies allowed.