Skip to content

Commit b2eb520

Browse files
Hello
1 parent 321dc1e commit b2eb520

File tree

2 files changed

+0
-83
lines changed

2 files changed

+0
-83
lines changed

activity_select.c

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -44,89 +44,6 @@ void activity_sel (int act)
4444
}
4545

4646

47-
int main ()
48-
{
49-
int i, act, wish;
50-
do
51-
{
52-
printf ("Enter the number of Activities to be done: ");
53-
scanf ("%d", &act);
54-
55-
printf ("Enter the start and end time of the activities: \n");
56-
for (i =0;i<act;i++)
57-
{
58-
printf ("%d-->", i+1);
59-
printf ("Start Time: ");
60-
scanf ("%d", &start[i]);
61-
printf ("\tEnd Time: ");
62-
scanf ("%d", &end[i]);
63-
}
64-
65-
for(i=0;i<act;i++)
66-
acti[i] = -1; // Setting all values of the acti array to -1
67-
68-
sort (act);
69-
70-
printf ("Start set: ");
71-
for (i = 0; i<act; i++)
72-
printf ("%d ", start[i]);
73-
printf ("\n");
74-
printf ("End set: ");
75-
for (i = 0; i<act; i++)
76-
printf ("%d ", end[i]);
77-
printf ("\n");
78-
79-
activity_sel (act);
80-
81-
printf ("Do you want to continue? (1/0): ");
82-
scanf ("%d", &wish);
83-
}while (wish!=0);
84-
#include <stdio.h>
85-
int start[100], end[100], acti[100];
86-
87-
void sort (int act) //Sorting the activities wrt finish time
88-
{
89-
int temp, i, j, temp2;
90-
for (i= act-1;i>=1; i--)
91-
{
92-
for (j=1;j<=i;j++)
93-
{
94-
if (end[j-1]>end[j])
95-
{
96-
temp = end[j];
97-
end[j]= end[j-1];
98-
end[j-1] = temp;
99-
100-
temp2 = start[j];
101-
start[j] = start[j-1];
102-
start[j-1] = temp2;
103-
}
104-
}
105-
}
106-
}
107-
108-
109-
void activity_sel (int act)
110-
{
111-
int i,j;
112-
acti[0] = 0;
113-
j = 0;
114-
for (i=1;i<act;i++)
115-
{
116-
if (start[i]>=end[j])
117-
{
118-
acti[i] = i;
119-
j=i;
120-
}
121-
}
122-
123-
printf ("Activity set: ");
124-
for (i = 0; i<act; i++)
125-
printf ("%d ", acti[i]);
126-
printf ("\n");
127-
}
128-
129-
13047
int main ()
13148
{
13249
int i, act, wish;

activity_select.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)