File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ void sort (int act) //Sorting the activities wrt finish time
25
25
26
26
void activity_sel (int act )
27
27
{
28
- int i ,j , c = 0 ;
28
+ int i ,j ;
29
29
acti [0 ] = 0 ;
30
30
j = 0 ;
31
31
for (i = 1 ;i < act ;i ++ )
@@ -34,15 +34,12 @@ void activity_sel (int act)
34
34
{
35
35
acti [i ] = i ;
36
36
j = i ;
37
- c ++ ;
38
37
}
39
- else
40
- c ++ ;
41
38
}
42
39
43
40
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 ]);
46
43
printf ("\n" );
47
44
}
48
45
@@ -65,16 +62,18 @@ int main ()
65
62
scanf ("%d" , & end [i ]);
66
63
}
67
64
68
-
65
+ for (i = 0 ;i < act ;i ++ )
66
+ acti [i ] = -1 ; // Setting all values of the acti array to -1
67
+
69
68
sort (act );
70
69
71
70
printf ("Start set: " );
72
71
for (i = 0 ; i < act ; i ++ )
73
- printf ("%d" , start [i ]);
72
+ printf ("%d " , start [i ]);
74
73
printf ("\n" );
75
74
printf ("End set: " );
76
75
for (i = 0 ; i < act ; i ++ )
77
- printf ("%d" , end [i ]);
76
+ printf ("%d " , end [i ]);
78
77
printf ("\n" );
79
78
80
79
activity_sel (act );
You can’t perform that action at this time.
0 commit comments