-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathos.cpp
More file actions
53 lines (47 loc) · 955 Bytes
/
os.cpp
File metadata and controls
53 lines (47 loc) · 955 Bytes
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
49
50
51
52
53
#include<bits/stdc++.h>
using namespace std;
int main()
{
int nb,np,temp,lowest=9999;
int a1[20],a2[20],b[20],p[20];
cout<<"Enter number of blocks ";
cin>>nb;
cout<<"Enter number of processes ";
cin>>np;
cout<<"Enter size of each block"<<endl;
for(int i=1;i<=nb;i++)
{
cout<<"Block "<<i<<"-";
cin>>b[i];
}
cout<<"\nEnter size of each process."<<endl;
for(int i=1;i<=np;i++)
{
cout<<"Process "<<i<<"-";
cin>>p[i];
}
for(int t=1;t<=np;t++)
{
for(int q=1;q<=nb;q++)
{
if(a1[q]!=1)
{
temp=b[q]-p[t];
if(temp>=0)
if(lowest>temp)
{
a2[t]=q;
lowest=temp;
}
}
}
a1[a2[t]]=1;
lowest=10000;
}
cout<<endl<<"Process number\tProcess size\tBlock number\tBlock size";
for(int i=1;(i<=np and a2[i]!=0);i++)
{
cout<<endl<<i<<"\t\t"<<p[i]<<"\t\t"<<a2[i]<<"\t\t"<<b[a2[i]];
}
return 0;
}