📄 dopage.cpp
字号:
#include <iostream>
#include <fstream>
#include "fifo.h"
#include "lru.h"
#include "scr.h"
using std::ifstream;
using std::cout;
int main(int argc,char *argv[])
{
if (argc != 4)
{
cout << "Error input!";
exit(1);
}
ifstream file( argv[3] );
if (!file.is_open())
{
cout << "Not fount page file!";
exit(2);
}
int page_max = atoi(argv[1]);
if (page_max < 3)
page_max = 3;
cout << "There are " << page_max << " pages AND ";
Mem_page *mp;
if(!strcmp(argv[2], "fifo"))
{
cout <<"Using FIFO Algorithm" << endl;
mp = new Fifo_page(page_max);
}
else if(!strcmp(argv[2], "lru"))
{
cout <<"Using LRU Algorithm" << endl;
mp = new Lru_page(page_max);
}
else
{
cout <<"Using SCR Algorithm" << endl;
mp = new Scr_page(page_max);
}
char page_id[10];
while (!file.eof())
{
file.getline(page_id, sizeof(page_id));
mp->do_page( atoi(page_id) );
mp->show_page();
}
file.close();
//mp->show_page();
delete mp;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -