给出一个磁盘块序列:1、2、3、……、500,初始状态所有块为空的,每块的大小为2k。使用位表来管理空闲块。
对于基于块的索引分配执行以下步骤:
随机生成2k-10k的文件50个,文件名为1.txt、2.txt、……、50.txt,按照上述算法存储到模拟磁盘中。
删除奇数.txt(1.txt、3.txt、……、49.txt)文件
新创建5个文件(A.txt、B.txt、C.txt、D.txt、E.txt),大小为:7k 4、5k 3、2k 1、9k 5、3.5k 2,按照与(1)相同的算法存储到模拟磁盘中。
给出文件A.txt、B.txt、C.txt、D.txt、E.txt的文件分配表和空闲区块的状态。
#include <iostream>
#include <sstream>
#include <vector>
#include <ctime>
#include <cstring>
using namespace std;
void initializeFiles();
void deleteOddFiles();
void new5Files();
char nth_letter(int n);
void printFreeBlocks();
typedef struct Fat//file allocation table 文件分配表
{
string name;
int indexBlock;//索引块号
}Fat;
//索引块
class IndexBlock {
public:
//指向另外5个块存放内容
int contents[5];
IndexBlock() {
for (int i = 0; i < 5;