内容发布更新时间 : 2024/11/15 20:53:27星期一 下面是文章的全部内容请认真阅读。
BEGIN_MESSAGE_MAP(CMyDlg, CDialog) //{{AFX_MSG_MAP(CMyDlg) ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_RADIO1, OnRadio1) ON_BN_CLICKED(IDC_RADIO2, OnRadio2) ON_BN_CLICKED(IDC_RADIO3, OnRadio3) ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) //}}AFX_MSG_MAP END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// // CMyDlg message handlers
BOOL CMyDlg::OnInitDialog() {
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control }
// If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework.
void CMyDlg::OnPaint() {
if (IsIconic()) {
// Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CPaintDC dc(this); // device context for painting
11
} else { } }
// The system calls this to obtain the cursor to display while the user drags // the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon() {
return (HCURSOR) m_hIcon; }
#include
struct Pro
{
int num,time; }; Pro p[M];
12
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
CDialog::OnPaint();
//内存页的结构体
void Input()
{ int s;
//随机数 int i;
srand(time(0));
s = rand()%M;
//cout<<\随机产生指令流------------\\n\ for (i=0; i //产生指令队列 { p[i].num=s; //任选一指令访问点m //每次运行时进程号不同,用来作为初始化随机数队列的种子 //输入函数,输入实际页号和实际页数 p[i+1].num=p[i].num+1; //顺序执行一条指令 p[i+2].num=(int)((float)p[i].num*(rand()/(RAND_MAX+1.0))); //执行前地址指令m' p[i+3].num=p[i+2].num+1; //顺序执行一条指令 s=(int)((float)(319-p[i+2].num)*(rand()/(RAND_MAX+1.0))) + p[i+2].num; } for(i=0;i int Search(int e,Pro*page1,int N) //查找内存中是否存在要调入的页面 { int t; Pro*page=new Pro[N]; page=page1; 13 p[i].time=0; p[5].num=13;p[6].num=32;p[7].num=22; ///测试数 /* p[0].num=10;p[1].num=22;p[2].num=33;p[3].num=44;p[4].num=50; 据1,2,3,4,5,1,3,2 fifo 5,1,2,4 LRU 5,1,3,2 opt置换1,2,3,5 for(int i=0;i int Max(Pro*page1,int N) { Pro*page=new Pro[N]; page=page1; int e=page[0].time,i=0; while(i } for(i=0;i if(e==page[i].time) return i; //找最长时间的下标 return -1; } int Compfu(Pro*page1,int i,int t,Pro p[M]) //找到最久不使用的页面 { Pro*page=new Pro[N]; page=page1; int count=0; for(int j=i;j } return count; 14 t=e/10; if(t==page[i].num) return i; return -1; //找出离现在时间最长的页面 if(e //找最长时间 if(page[t].num==p[j].num/10) break; else ++count; //当前页面开始往后查找在内存中的页帧号 } void CMyDlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(true); Input(); //————————地址流———————— CString str1,tmp1; tmp1=str1=\ int k=0,t=0,i=0; for(i=0;i m_suiji.SetWindowText(_T(str1)); //————————页面流———————— CString str2,tmp2; tmp2=str2=\ for(i=0;i m_suiji2.SetWindowText(_T(str2)); tmp1.Format(\str1+=tmp1; k++; if(k==0) { } str1+=\ tmp2.Format(\str2+=tmp2; k++; if(k==0) { } str2+=\ Pro*page=new Pro[N];