diff --git a/Codes/Group B/Code-B6.cpp b/Codes/Group B/Code-B6.cpp index a047ffb..7e1e2db 100644 --- a/Codes/Group B/Code-B6.cpp +++ b/Codes/Group B/Code-B6.cpp @@ -1,117 +1,96 @@ -#include +#include using namespace std; -int blksize[] = {100, 500, 200, 300, 600}; +int blocks[] = {100, 500, 200, 300, 600}; int processes[] = {212, 417, 112, 426}; +int blkSize = sizeof(blocks) / sizeof(blocks[0]); +int prSize = sizeof(processes) / sizeof(processes[0]); -void firstfit(int pr[], int pr_size, int blk[], int blk_size) -{ - for(int i = 0; i < pr_size; i++) - { - bool check = false; - for(int j = 0; j < blk_size; j++) - { - if((blk[j] - pr[i]) >= 0) - { - blk[j] = blk[j] - pr[i]; - cout<<"\nProcess with value "<= 0)) { + blocks[j] -= processes[i]; + check = true; + cout<= 0 && (blk[j] - pr[i]) < store) - { - k = j + 1; - store = blk[j] - pr[i]; - check = true; - } - } - if(!check) - { - cout<<"\nProcess with value "<= 0 && (blk[j] - pr[i]) > store) - { - k = j + 1; - store = blk[j] - pr[i]; - check = true; - } - } - if(!check) - { - cout<<"\nProcess with value "<= 0) { + blocks[j] = blocks[j] - processes[i]; + cout<= 0) - { - blk[j] = blk[j] - pr[i]; - cout<<"\nProcess with value "<= 0 && (blocks[j] - processes[i]) < store) { + k = j + 1; + store = blocks[j] - processes[i]; + check = true; + } + } + if (check == false) { + cout<= 0 && (blocks[j] - processes[i] > store))) { + k = j + 1; + store = blocks[j] - processes[i]; + check = true; + } + } + if (check == false) { + cout<