-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivityIteam.cpp
48 lines (40 loc) · 1.02 KB
/
activityIteam.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<bits/stdc++.h>
using namespace std;
struct acitivity
{
char c;
int start_time, second_time;
};
bool aSort(acitivity a1, acitivity a2)
{
return (a1.second_time < a2.second_time);
}
int main()
{
int n;
cout << "Enter Activity Number: ";
cin >> n;
acitivity aArr[n];
for(int i = 0; i<n; i++)
{
cin >> aArr[i].c >> aArr[i].start_time >> aArr[i].second_time;
}
sort(aArr,aArr+n, aSort);
cout << "Activity Numbers sort by end time :" << endl;
for(int i = 0; i<n; i++)
{
cout << aArr[i].c << " " <<aArr[i].start_time << " " << aArr[i].second_time << endl;
}
cout << " " << "Activity Number : " << endl;
int i = 0;
cout<< aArr[i].c << " " <<aArr[i].start_time << " " << aArr[i].second_time << endl;
for(int j = 1; j<n; j++)
{
if(aArr[j].start_time>=aArr[i].second_time)
{
cout << aArr[j].c << " " <<aArr[j].start_time << " " << aArr[j].second_time << endl;
i=j;
}
}
return 0;
}