Printout 8
Printout 8
#include <iostream>
#include <vector>
#include <iomanip>
struct Block {
int size;
int fragment;
bool allocated;
};
int main() {
std::vector<Block> blocks(numBlocks);
std::cout << "Enter size of block " << i + 1 << ": ";
blocks[i].allocated = false;
std::cout << std::left << std::setw(10) << "File No" << std::setw(10) << "File Size" << std::setw(10) << "Block
No" << std::setw(12) << "Block Size" << "Fragment" << std::endl;
std::cout << "Enter size of file " << i + 1 << ": ";
blocks[j].allocated = true;
blocks[j].fragment = blocks[j].size - fileSize;
std::cout << std::left << std::setw(10) << i + 1 << std::setw(10) << fileSize << std::setw(10) << j + 1 <<
std::setw(12) << blocks[j].size << blocks[j].fragment << std::endl;
break;
return 0;
}
#include <iostream>
struct Block {
int size;
int fragment;
bool allocated;
};
int allocation[n];
allocation[i] = -1;
if (bestIdx == -1)
bestIdx = j;
bestIdx = j;
if (bestIdx != -1) {
allocation[i] = bestIdx;
blockSize[bestIdx] -= processSize[i];
cout << " " << i + 1 << "\t\t" << processSize[i] << "\t\t";
if (allocation[i] != -1)
else
int main() {
return 0;
}
#include <iostream>
struct Block {
int size;
int fragment;
bool allocated;
};
int allocation[n];
allocation[i] = -1;
if (worstIdx == -1)
worstIdx = j;
worstIdx = j;
if (worstIdx != -1) {
allocation[i] = worstIdx;
blockSize[worstIdx] -= processSize[i];
cout << " " << i + 1 << "\t\t" << processSize[i] << "\t\t";
if (allocation[i] != -1)
else
int main() {
return 0;