分支限界法之装载问题

上传人:kms****20 文档编号:40441633 上传时间:2018-05-26 格式:DOC 页数:16 大小:35.50KB
返回 下载 相关 举报
分支限界法之装载问题_第1页
第1页 / 共16页
分支限界法之装载问题_第2页
第2页 / 共16页
分支限界法之装载问题_第3页
第3页 / 共16页
分支限界法之装载问题_第4页
第4页 / 共16页
分支限界法之装载问题_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《分支限界法之装载问题》由会员分享,可在线阅读,更多相关《分支限界法之装载问题(16页珍藏版)》请在金锄头文库上搜索。

1、分支限界法之装载问题分支限界法之装载问题#include “Queue.h“#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;/AFX_DATA/ ClassWizard genera

2、ted virtual function overrides/AFX_VIRTUAL(CAboutDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:/AFX_MSG(CAboutDlg)/AFX_MSGDECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INI

3、Tvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg)/ No message handlers/AFX_MSG_MAPEND_MESSAGE_MAP()/ CNewDlg dialogCNewDlg:CNewDlg(CWnd* pParent /*=NULL*/): CDialog(CNewDlg:I

4、DD, pParent)/AFX_DATA_INIT(CNewDlg)m_num = _T(“);/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CNewDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CNewDlg)DDX_Text(pDX, IDC_EDIT_

5、NUM, m_num);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CNewDlg, CDialog)/AFX_MSG_MAP(CNewDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BTN_LOAD, OnBtnLoad) ON_BN_CLICKED(IDC_BTN_CLEAR, OnBtnClear)/AFX_MSG_MAPEND_MESSAGE_MAP()/ CNewDlg message handlersBOOL CNewDlg:OnInitDialog()CDialo

6、g:OnInitDialog();/ Add “About.“ menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automaticall

7、y/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE); / Set big icon SetIcon(m_hIcon, FALSE); / Set small icon/ TODO: Add extra initialization herenum=0;j=0;num_pri=0;boxmark_str=“;m_num=“;return TRUE; / return TRUE unless you set the focus to a controlvoid CNewDlg:OnSysCommand

8、(UINT nID, LPARAM lParam)if (nID dlgAbout.DoModal();elseCDialog: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 CNe

9、wDlg:OnPaint()if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(int x = (rect.Width() -

10、cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CNewDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CNewDlg:EnQueue(

11、Queue *p_obj, int wt, int else p_obj- add(wt);int CNewDlg:MaxLoading()p_obj=new Queue(1000);p_obj-add(-1);int i=0;/重大修改 int i=1;int Ew=0;bestw=0;while(true)if(Ew+wi Delete();if(Ew=-1)if(p_obj- Isempty()return bestw;p_obj- add(-1);Ew=p_obj- Delete();i+;void CNewDlg:OnBtnLoad()/ TODO: Add your control

12、 notification handler code hereGetDlgItemText(IDC_EDIT_AMOUNT,str);/箱子的数目n=atoi(str);/ int *ptr=new int n;w=new intn;GetDlgItemText(IDC_EDIT_NUM,m_num);int m=m_num.GetLength();p=new charm+1;/ strcpy(p,s_num);for(int i=0;im;i+)pi=m_num.GetAt(i);for( i=0;im;i+)if(pi!=44) / num=atom(s.GetAt(i);pi-=48;n

13、um=pi;num_pri=num_pri*10+num;/ num=0;else/ num=num/10;if(jn)wj=num_pri;j+;num_pri=0;/ ss=wj;GetDlgItemText(IDC_EDIT_MAXLOAD,s_maxload);c=atoi(s_maxload);MaxLoading();ss.Format(“%d“,bestw); SetDlgItemText(IDC_EDIT_OUTPUT,“轮船的最大载重量是:“+ss);void CNewDlg:OnBtnClear()/ TODO: Add your control notification handler code herenum=0;j=0;num_pri=0;c=0;n=0;GetDlgItemText(IDC_EDIT_NUM,m_num);if(m_num!=“)deletew;deletep;deletep_obj;elseAfxMessageBox(“没有输入有效字符!“);/ m_num=“;SetDlgItemText(IDC_EDIT_OUTPUT,“); SetDlgItemText(IDC_EDIT_AMOUNT,“); SetDlgItemText(IDC_EDIT_MAXLOAD,“); SetDlgItemText(IDC_EDIT_NUM,“);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号