Untitled
unknown
plain_text
a year ago
961 B
3
Indexable
#include<stdio.h> #define max 20 int main() { int np,nb,p[max],b[max],i,j; printf("Enter the no of blocks:\n"); scanf("%d",&nb); printf("Enter the no of processes:\n"); scanf("%d",&np); printf("Enter the size of each block:\n"); for(i=1;i<=nb;i++) { printf("Block%d:",i); scanf("%d",&b[i]); } printf("Enter the size of each process:\n"); for(i=1;i<=np;i++) { printf("process%d:",i); scanf("%d",&p[i]); } for(i=1;i<=nb;i++) { for(j=1;j<=np;j++) { if(p[j]<=b[i]) { printf("the process %d allocated to block %d\n",j,b[i]); p[j]=10000; break; } } } for(j=1;j<=np;j++) { if(p[j]!=10000) { printf("the process %d is not allocated\n",j); } } return 0; }
Editor is loading...
Leave a Comment