Skip to content

Commit c2a0a2c

Browse files
New Commit
1 parent 0840a1c commit c2a0a2c

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

activity_select.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void sort (int act) //Sorting the activities wrt finish time
2525

2626
void activity_sel (int act)
2727
{
28-
int i,j, c=0;
28+
int i,j;
2929
acti[0] = 0;
3030
j = 0;
3131
for (i=1;i<act;i++)
@@ -34,15 +34,12 @@ void activity_sel (int act)
3434
{
3535
acti[i] = i;
3636
j=i;
37-
c++;
3837
}
39-
else
40-
c++;
4138
}
4239

4340
printf ("Activity set: ");
44-
for (i = 0; i<=c; i++)
45-
printf ("%d", acti[i]);
41+
for (i = 0; i<act; i++)
42+
printf ("%d ", acti[i]);
4643
printf ("\n");
4744
}
4845

@@ -65,16 +62,18 @@ int main ()
6562
scanf ("%d", &end[i]);
6663
}
6764

68-
65+
for(i=0;i<act;i++)
66+
acti[i] = -1; // Setting all values of the acti array to -1
67+
6968
sort (act);
7069

7170
printf ("Start set: ");
7271
for (i = 0; i<act; i++)
73-
printf ("%d", start[i]);
72+
printf ("%d ", start[i]);
7473
printf ("\n");
7574
printf ("End set: ");
7675
for (i = 0; i<act; i++)
77-
printf ("%d", end[i]);
76+
printf ("%d ", end[i]);
7877
printf ("\n");
7978

8079
activity_sel (act);

activity_select.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)