📄 磁盘调度dlg.cpp
字号:
// 磁盘调度Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "磁盘调度.h"
#include "磁盘调度Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_previous = 0;
m_present = 0;
m_list6 = 0;
m_list7 = 0;
m_list8 = 0;
m_list9 = 0;
m_list10 = 0;
m_list3 = 0;
m_list4 = 0;
m_list5 = 0;
m_list1 = 0;
m_list2 = 0;
list1 = 0;
list2 = 0;
list3 = 0;
list4 = 0;
list5 = 0;
list6 = 0;
list7 = 0;
list8 = 0;
list9 = 0;
list10 = 0;
m_length = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Text(pDX, IDC_EDIT1, m_previous);
DDX_Text(pDX, IDC_EDIT2, m_present);
DDX_Text(pDX, IDC_EDIT10, m_list6);
DDX_Text(pDX, IDC_EDIT11, m_list7);
DDX_Text(pDX, IDC_EDIT12, m_list8);
DDX_Text(pDX, IDC_EDIT13, m_list9);
DDX_Text(pDX, IDC_EDIT14, m_list10);
DDX_Text(pDX, IDC_EDIT7, m_list3);
DDX_Text(pDX, IDC_EDIT8, m_list4);
DDX_Text(pDX, IDC_EDIT9, m_list5);
DDX_Text(pDX, IDC_EDIT5, m_list1);
DDX_Text(pDX, IDC_EDIT6, m_list2);
DDX_Text(pDX, IDC_EDIT15, list1);
DDX_Text(pDX, IDC_EDIT16, list2);
DDX_Text(pDX, IDC_EDIT17, list3);
DDX_Text(pDX, IDC_EDIT18, list4);
DDX_Text(pDX, IDC_EDIT19, list5);
DDX_Text(pDX, IDC_EDIT20, list6);
DDX_Text(pDX, IDC_EDIT21, list7);
DDX_Text(pDX, IDC_EDIT22, list8);
DDX_Text(pDX, IDC_EDIT23, list9);
DDX_Text(pDX, IDC_EDIT24, list10);
DDX_Text(pDX, IDC_EDIT25, m_length);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_CANCELMODE()
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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())
{
CPaintDC dc(this); // device context for painting
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);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyDlg::Ccreate1(int x1,int x2,int x3,int x4,int x5,int x6,int x7,int x8,int x9,int x10)
{int x[10];
m_length=0;
x[0]=x1; x[1]=x2; x[2]=x3; x[3]=x4; x[4]=x5; x[5]=x6; x[6]=x7; x[7]=x8; x[8]=x9; x[9]=x10;
length(x,m_present);
list1=x[0]; list2=x[1]; list3=x[2]; list4=x[3]; list5=x[4]; list6=x[5]; list7=x[6]; list8=x[7]; list9=x[8]; list10=x[9];
}
void CMyDlg::Ccreate2(int x1,int x2,int x3,int x4,int x5,int x6,int x7,int x8,int x9,int x10)
{int x[10],a[10];
int i=0;
m_length=0;
x[0]=x1; x[1]=x2; x[2]=x3; x[3]=x4; x[4]=x5; x[5]=x6; x[6]=x7; x[7]=x8; x[8]=x9; x[9]=x10;
sort_min(x,0,10);
if(m_present>x[9])
sort_max(x,0,10);
else if(m_present>x[0])
{while(x[i]<m_present)
i++;
int s=i;
if(x[s]-m_present<m_present-x[s-1])
{sort_max(x,0,s);
for(i=0;i<s;i++)
a[i]=x[i];
for(i=0;i<10-s;i++)
x[i]=x[i+s];
for(i=0;i<s;i++)
x[10-s+i]=a[i];
}
else
sort_max(x,0,s);
}
length(x,m_present);
list1=x[0]; list2=x[1]; list3=x[2]; list4=x[3]; list5=x[4]; list6=x[5]; list7=x[6]; list8=x[7]; list9=x[8]; list10=x[9];
}
void CMyDlg::Ccreate3(int x1,int x2,int x3,int x4,int x5,int x6,int x7,int x8,int x9,int x10)
{int u,x[10],a[10],s;
int i=0;
m_length=0;
x[0]=x1; x[1]=x2; x[2]=x3; x[3]=x4; x[4]=x5; x[5]=x6; x[6]=x7; x[7]=x8; x[8]=x9; x[9]=x10;
sort_min(x, 0, 10);
u=m_present-m_previous;
if(m_present>x[9])
sort_max(x,0,10);
else if(m_present>x[0])
{while(x[i]<m_present)
i++;
s=i;
if(u<0)
sort_max(x,0,s);
else
{sort_max(x,0,s);
for(i=0;i<s;i++)
a[i]=x[i];
for(i=0;i<10-s;i++)
x[i]=x[i+s];
for(i=0;i<s;i++)
x[10-s+i]=a[i];}
}
length(x,m_present);
list1=x[0]; list2=x[1]; list3=x[2]; list4=x[3]; list5=x[4]; list6=x[5]; list7=x[6]; list8=x[7]; list9=x[8]; list10=x[9];
}
void CMyDlg::Ccreate4(int x1,int x2,int x3,int x4,int x5,int x6,int x7,int x8,int x9,int x10)
{int x[10],u,s,a[10];
int i=0;
m_length=0;
x[0]=x1; x[1]=x2; x[2]=x3; x[3]=x4; x[4]=x5; x[5]=x6; x[6]=x7; x[7]=x8; x[8]=x9; x[9]=x10;
sort_min(x, 0, 10);
u=m_present-m_previous;
if(u<0)
{if(m_present<x[0]||m_present>x[9])
sort_max(x, 0, 10);
else
{while(x[i]<m_present)
i++;
s=i;
sort_max(x,0,s);
sort_max(x,s,10);}
}
else
{if (m_present>x[0]&&m_present<x[9])
while(x[i]<m_present)
i++;
s=i;
for(i=0;i<s;i++)
a[i]=x[i];
for(i=0;i<10-s;i++)
x[i]=x[i+s];
for(i=10-s;i<10;i++)
x[i]=a[i+s-10];
}
length(x,m_present);
list1=x[0]; list2=x[1]; list3=x[2]; list4=x[3]; list5=x[4]; list6=x[5]; list7=x[6]; list8=x[7]; list9=x[8]; list10=x[9];
}
void CMyDlg::sort_min(int x[],int begin,int n)
{for(int i=begin;i<n-1;i++)
{int min=x[i];
int min_no=i;
for(int j=i+1;j<n;j++)
{if (x[j]<min)
{min=x[j];
min_no=j;}
}
if (i!=min_no)
{int t=x[i]; x[i]=x[min_no];x[min_no]=t;}
}
}
void CMyDlg::sort_max(int x[],int begin,int n)
{for(int i=begin;i<n-1;i++)
{int max=x[i];
int max_no=i;
for(int j=i+1;j<n;j++)
{if (x[j]>max)
{max=x[j];
max_no=j;}
}
if (i!=max_no)
{int t=x[i]; x[i]=x[max_no];x[max_no]=t;}
}
}
void CMyDlg::length(int x[],int m_present)
{int i,t,v;
for(i=1;i<10;i++)
{t=x[i]-x[i-1];
if (t<0) t=-t;
m_length=m_length+t;}
v=m_present-x[0];
if (v<0) v=-v;
m_length=m_length+v;
}
void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(true);
Ccreate1(m_list1,m_list2,m_list3,m_list4,m_list5,m_list6,m_list7,m_list8,m_list9,m_list10);
UpdateData(false);
}
void CMyDlg::OnCancelMode()
{
CDialog::OnCancelMode();
// TODO: Add your message handler code here
}
void CMyDlg::OnButton2()
{
// TODO: Add your control notification handler code here
UpdateData(true);
Ccreate2(m_list1,m_list2,m_list3,m_list4,m_list5,m_list6,m_list7,m_list8,m_list9,m_list10);
UpdateData(false);
}
void CMyDlg::OnButton3()
{
// TODO: Add your control notification handler code here
UpdateData(true);
Ccreate3(m_list1,m_list2,m_list3,m_list4,m_list5,m_list6,m_list7,m_list8,m_list9,m_list10);
UpdateData(false);
}
void CMyDlg::OnButton4()
{
// TODO: Add your control notification handler code here
UpdateData(true);
Ccreate4(m_list1,m_list2,m_list3,m_list4,m_list5,m_list6,m_list7,m_list8,m_list9,m_list10);
UpdateData(false);
}
void CMyDlg::OnButton5()
{
// TODO: Add your control notification handler code here
m_list1=m_list2=m_list3=m_list4=m_list5=m_list6=m_list7=m_list8=m_list9=m_list10=0;
list1=list2=list3=list4=list5=list6=list7=list8=list9=list10=m_length=m_previous=m_present=0;
UpdateData(false);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -