?? computerosexp_04_02.cpp
字號:
#include "stdafx.h"
#include "MBT.h"
#include "MBTList.h"
#include <iostream.h>
#include "PCB.h"
char *name[4] = {"AA", "BB", "CC", "DD"};
int fpPCBLen[4] = {5, 20, 10, 20};
int fpStartAdd[4] = {20, 35, 70, 110};
int fpLen[4] = {5, 20, 10, 20};
int kxStartAdd[4] = {25, 55, 80, 130};
int kxLen[4] = {10, 15, 30, 20};
void Print(MBTList *fpList, MBTList *kxList)
{
cout << "初始數據" << endl;
cout << "已分區" << endl;
fpList->Print();
cout << "未分區" << endl;
kxList->Print();
cout << endl << endl << endl;
}
void DestributM(MBTList *fpList, MBTList *kxList, PCB *pcb, int sort)
{
MBT *mbt = kxList->Destribute(pcb);
fpList->InsertMBT(mbt, sort);
cout << "分配" << pcb->name << "后的數據" << endl;
cout << "已分區" << endl;
fpList->Print();
cout << "未分區" << endl;
kxList->Print();
}
void RecyleM(MBTList *fpList, MBTList *kxList, char *name, int sort)
{
cout << endl << endl << endl;
MBT *get = fpList->Recyle(name);
kxList->UnionMBT(get, sort);
cout << "回收" << name << "后的數據" << endl;
cout << "已分區" << endl;
fpList->Print();
cout << "未分區" << endl;
kxList->Print();
}
int main(int argc, char* argv[])
{
int sort = 1;
MBTList *fpList = new MBTList();
MBTList *kxList = new MBTList();
for(int i = 0; i < 4; i++)
{
PCB *pcb = new PCB(name[i], fpPCBLen[i]);
MBT *fpMBT = new MBT(1, pcb);
fpMBT->startAdd = fpStartAdd[i];
fpMBT->len = fpLen[i];
fpList->InsertMBT(fpMBT, sort);
MBT *kxMBT = new MBT(0, 0);
kxMBT->startAdd = kxStartAdd[i];
kxMBT->len = kxLen[i];
kxList->InsertMBT(kxMBT, sort);
}
Print(fpList, kxList);
char *n = "EE";
int fpL = 17;
PCB *p = new PCB(n, fpL);
DestributM(fpList, kxList, p, sort);
RecyleM(fpList, kxList, "EE", sort);
RecyleM(fpList, kxList, "CC", sort);
delete kxList, fpList;
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -