-
Notifications
You must be signed in to change notification settings - Fork 0
/
BestFit.c
39 lines (39 loc) · 902 Bytes
/
BestFit.c
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
#include <stdio.h>
#include <process.h>
void main()
{
int a[20], p[20], i, j, n, m;
printf("Enter no of Blocks.\n");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("Enter the %dst Block size:", i);
scanf("%d", &a[i]);
}
printf("Enter no of Process.\n");
scanf("%d", &m);
for (i = 0; i < m; i++)
{
printf("Enter the size of %dst Process:", i);
scanf("%d", &p[i]);
}
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
if (p[j] <= a[i])
{
printf("The Process %d allocated to %d\n", j, a[i]);
p[j] = 10000;
break;
}
}
}
for (j = 0; j < m; j++)
{
if (p[j] != 10000)
{
printf("The Process %d is not allocated\n", j);
}
}
}