1、/ 两校间最短路径查询器 Dlg.cpp : implementation file/#include “stdafx.h“#include “两校间最短路径查询器.h“#include “两校间最短路径查询器 Dlg.h“#ifdef _DEBUG#define new DEBUG_NEW#define CHENGYUAN 0#define NONGDA 1#define JIAODA 2#define ZHENGFA 3#define SHIDA 4#define ZHIXING 5#define MAXSIZE 20 #define MAXVALUE 214748364.0#define
2、 SWAP(a, b) temp = a; a = b; b = temp; void floyd(float distMAXSIZE, int pathMAXSIZE, int n);/void display_path(float MAXSIZE, float MAXSIZE, int n);void reverse(int x, int n);/float distMAXSIZEMAXSIZE;int pathMAXSIZEMAXSIZE;int n;char resourMAXSIZE;char distanMAXSIZE;float dist2020=0.0,0.5,MAXVALUE
3、,MAXVALUE,MAXVALUE,MAXVALUE,0.5,0.0,3.3,3.5,3.3,MAXVALUE,MAXVALUE,3.3,0.0,0.4,MAXVALUE,MAXVALUE,MAXVALUE,3.5,0.4,0.0,0.4,0.7,MAXVALUE,3.3,MAXVALUE,0.4,0.0,0.9,MAXVALUE,MAXVALUE,MAXVALUE,0.7,0.9,0.0;#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CAboutDlg dialog used for App Aboutclass CAbout
4、Dlg : public CDialogpublic: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/ Implementationprotected:/AFX_MS
5、G(CAboutDlg)/AFX_MSGDECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg
6、)/ No message handlers/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMyDlg dialogCMyDlg:CMyDlg(CWnd* pParent /*=NULL*/): CDialog(CMyDlg:IDD, pParent)/AFX_DATA_INIT(CMyDlg)m_School = _T(“);m_School1 = _T(“);m_School2 = _T(“);m_Path = _T(“);/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon
7、 in Win32m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CMyDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CMyDlg)DDX_Control(pDX, IDC_BUTTON1, m_Button1);DDX_Control(pDX, IDC_BUTTON2, m_Button2);DDX_Text(pDX, IDC_EDIT_SCHOOL, m_School);DDX_Text(pDX, IDC_EDIT_SCHO
8、OL1, m_School1);DDX_Text(pDX, IDC_EDIT_SCHOOL2, m_School2);DDX_Text(pDX, IDC_EDIT_PATH, m_Path);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CMyDlg, CDialog)/AFX_MSG_MAP(CMyDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BUTTON1, OnButton1)ON_BN_CLICKED(IDC_BUTTON2, OnButton2)/AFX_MSG_MA
9、PEND_MESSAGE_MAP()/ CMyDlg message handlersBOOL CMyDlg:OnInitDialog()CDialog: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, strAbou
10、tMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE); / Set big iconSetIcon(m_hIcon, FALSE); / Set small icon/ TODO: Add extra initialization herereturn TRUE; / return TRUE unless you set the focus to a
11、controlvoid CMyDlg:OnSysCommand(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
12、you by the framework.void CMyDlg: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;GetClient
13、Rect(int x = (rect.Width() - 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 CMyDlg:OnQueryDragIcon()return (HCURSOR) m_
14、hIcon;/ 函数 floydvoid floyd(float distMAXSIZE, int pathMAXSIZE, int n)int i, j, k;for (i = 0; i distik+distkj) pathij = pathkj; distij = distik+distkj;void reverse(int x, int n)int i, j, temp;for (i = 0, j = n-1; i “; break;case NONGDA: tem=tem+“农业大学“ ; break;case JIAODA : tem=tem+“交通大学“ ;break;case
15、ZHENGFA: tem=tem+“政法大学“; break;case SHIDA : tem=tem+“师范大学“ ;break;case ZHIXING:tem=tem+“知行学院“ ;break;switch(t)case CHENGYUAN: tem=tem+“城市学院“ ;break;case NONGDA: tem=tem+“农业大学“; break;case JIAODA : tem=tem+“交通大学“ ;break;case ZHENGFA: tem=tem+“政法大学“; break;case SHIDA : tem=tem+“师范大学“ ;break;case ZHIXING:tem=tem+“知行学院“ ;break;m_School.Format(“%s“,tem);free(chain);UpdateData(FALSE);void CMyDlg:OnButton2() OnOK();