Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
992 B
0
Indexable
Never
include<stdio.h>
int main()
{
 int  n,m,i,j,k;
printf ("enter the  no of processes");
scanf("%d",&n);
printf("enter the no of resources");
scanf("%d",&m);
int alloc[m][n];
int max[m][n];
int avail[m];
printf ("enter the allocation matrix");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&alloc[i][j]);
}
}
printf("enter max matrix");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&max[i][j]);
}
}
printf("enter the available");
for(i=0;i<m;i++)
{
scanf("%d",&avail[i]);
}
int f[n], ans[n], ind = 0;
    for (k = 0; k < n; k++) {
        f[k] = 0;
    }
    int need[n][m];
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++)
            need[i][j] = max[i][j] - alloc[i][j];
    }
    int y = 0;
    for (k = 0; k < 5; k++) {
        for (i = 0; i < n; i++) {
            if (f[i] == 0) {

                int flag = 0;
                for (j = 0; j < m; j++) {
                    if (need[i][j] > avail[j]){
                        flag = 1;
                         break;
Leave a Comment