|
|
|
|
#include<iostream>
|
|
|
|
|
#include<graphics.h>
|
|
|
|
|
#include"MyGraph.h"
|
|
|
|
|
#include<cmath>
|
|
|
|
|
#include<stack>
|
|
|
|
|
#include<fstream>
|
|
|
|
|
#include<string>
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<io.h>
|
|
|
|
|
#include"Function.h"
|
|
|
|
|
#include"Stack.h"
|
|
|
|
|
#include"MessageBox.h"
|
|
|
|
|
#include"Account.h"
|
|
|
|
|
|
|
|
|
|
#define WIDTH (915 + (LEFTBORDER * 2))
|
|
|
|
|
#define HEIGHT (722 + TOPBORDER + LEFTBORDER)
|
|
|
|
|
#define UP 72
|
|
|
|
|
#define DOWN 80
|
|
|
|
|
#define BACKGROUND "seu map.png"
|
|
|
|
|
#define BKCOLOR RGB(240, 240, 240)
|
|
|
|
|
#define SELECTCOLOR RGB(255, 0, 0)
|
|
|
|
|
#define TEXTCOLOR RGB(7, 102, 198)
|
|
|
|
|
#define MENUCOLOR (208, 161, 227)
|
|
|
|
|
#define CheckCancel if(is_cancel) {return -1;}
|
|
|
|
|
|
|
|
|
|
int choose;
|
|
|
|
|
Graph_List graph;
|
|
|
|
|
Account account;
|
|
|
|
|
const int menu_num = 11;
|
|
|
|
|
int menu_top1 = 10;
|
|
|
|
|
int menu_top = menu_top + 3;
|
|
|
|
|
#define left (LEFTBORDER)
|
|
|
|
|
// <20><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD>߶ȺͿ<C8BA><CDBF><EFBFBD>
|
|
|
|
|
int menu_width = ((WIDTH - 2 * LEFTBORDER) / (menu_num));
|
|
|
|
|
int menu_height = 30;
|
|
|
|
|
EasyTextBox txt_name;
|
|
|
|
|
EasyTextBox txt_password;
|
|
|
|
|
EasyButton btnOK;
|
|
|
|
|
|
|
|
|
|
int get_choose();
|
|
|
|
|
int front_menu(Graph_List & graph); // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
int show_all_vertex(Graph_List & graph); // <20><>ʾ<EFBFBD><CABE><EFBFBD>нڵ<D0BD>
|
|
|
|
|
int show_all_path(Graph_List & graph); // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
|
|
|
|
|
// <20><>ʾ·<CABE><C2B7>
|
|
|
|
|
int printroad(int dx, int dy, int sx, int sy) {
|
|
|
|
|
LINESTYLE linestyle; // <20><><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>ʽ
|
|
|
|
|
getlinestyle(&linestyle);
|
|
|
|
|
setlinestyle(PS_SOLID, 3, NULL, 0);
|
|
|
|
|
line(sx, sy, dx, dy);
|
|
|
|
|
setlinestyle(&linestyle);
|
|
|
|
|
double x1 = (sx + dx) / 2;
|
|
|
|
|
double y1 = (sy + dy) / 2;
|
|
|
|
|
double x2 = ((3.0 / 8.0) * sx + (5.0 / 8.0) * dx);
|
|
|
|
|
double y2 = ((3.0 / 8.0) * sy + (5.0 / 8.0) * dy);
|
|
|
|
|
double k1 = (y2 - y1) / (x2 - x1);
|
|
|
|
|
double k2 = (-1) / k1;
|
|
|
|
|
double delta = 1600;
|
|
|
|
|
double a = sqrt((delta / 16) / (1 + k2 * k2));
|
|
|
|
|
double b = a * fabs(k2);
|
|
|
|
|
if (((x1 > x2) && (y1 < y2)) || ((x1 < x2) && (y1 > y2))) {
|
|
|
|
|
}
|
|
|
|
|
else b = -1 * b;
|
|
|
|
|
if (x1 == x2) {
|
|
|
|
|
a = 5;
|
|
|
|
|
b = 0;
|
|
|
|
|
}
|
|
|
|
|
if (y1 == y2) {
|
|
|
|
|
a = 0;
|
|
|
|
|
b = 3;
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
POINT pts[] = { {x1, y1}, {x2 + a, y2 + b}, {(x1 + x2) / 2, (y1 + y2) / 2} };
|
|
|
|
|
POINT pts1[] = { {x1, y1}, {x2 * 2 - (x2 + a), y2 * 2 - (y2 + b)}, {(x1 + x2) / 2, (y1 + y2) / 2} };
|
|
|
|
|
setfillcolor(BLUE);
|
|
|
|
|
solidpolygon(pts1, 3); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>Σ<EFBFBD><CEA3>ޱ߿<DEB1><DFBF><EFBFBD>
|
|
|
|
|
solidpolygon(pts, 3);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
int get_mouse_xy(int& mousex, int& mousey) {
|
|
|
|
|
MOUSEMSG temp;
|
|
|
|
|
temp.mkLButton = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool kick = false;
|
|
|
|
|
while (!kick) {
|
|
|
|
|
temp = GetMouseMsg();
|
|
|
|
|
FlushMouseMsgBuffer();
|
|
|
|
|
if (temp.mkLButton == false) {
|
|
|
|
|
mousex = temp.x;
|
|
|
|
|
mousey = temp.y;
|
|
|
|
|
}
|
|
|
|
|
else kick = temp.mkLButton;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD>
|
|
|
|
|
int add_vertex(Graph_List& graph) {
|
|
|
|
|
LOGFONT font;
|
|
|
|
|
gettextstyle(&font);
|
|
|
|
|
settextstyle(10, 0, _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|
|
|
|
BeginBatchDraw();
|
|
|
|
|
setlinecolor(GREEN);
|
|
|
|
|
for (int lx = LEFTBORDER; lx <= WIDTH; lx += 50) {
|
|
|
|
|
line(lx, TOPBORDER, lx, HEIGHT - LEFTBORDER);
|
|
|
|
|
}
|
|
|
|
|
for (int ly = TOPBORDER; ly <= HEIGHT - LEFTBORDER; ly += 50) {
|
|
|
|
|
line(LEFTBORDER, ly, WIDTH - LEFTBORDER, ly);
|
|
|
|
|
}
|
|
|
|
|
FlushBatchDraw();
|
|
|
|
|
setlinecolor(MENUCOLOR);
|
|
|
|
|
settextstyle(&font);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
int mousex, mousey;
|
|
|
|
|
get_mouse_xy(mousex, mousey);
|
|
|
|
|
char name[30];
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
is_cancel = !InputBox((LPTSTR)name, 30, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
char description[1000];
|
|
|
|
|
is_cancel = !InputBox((LPTSTR)(&(description[0])), 1000, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ctrl+Enterȷ<72><C8B7><EFBFBD><EFBFBD><EFBFBD>룩", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 10, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
char mark[10];
|
|
|
|
|
int marki;
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(mark[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD>", 0, 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
marki = str_to_num(mark);
|
|
|
|
|
if (marki > 0 && graph.get_index(marki) == -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
std::string namestr = "", descriptionstr = "";
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>뵽<EFBFBD>ڵ<EFBFBD>
|
|
|
|
|
graph.insert_vertex((std::string)(namestr + name), (std::string)(descriptionstr + description), marki, mousex, mousey);
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int add_path(Graph_List& graph) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
int v1, v2;
|
|
|
|
|
std::string source = "0000000000", destination = "0000000000", weightstr = "0000000000";
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(source[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = str_to_num(source);
|
|
|
|
|
if (graph.get_index(v1) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(destination[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v2 = str_to_num(destination);
|
|
|
|
|
if (graph.get_index(v2) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
double dx = graph.get_head()[graph.get_index(v2)].get_x();
|
|
|
|
|
double sx = graph.get_head()[graph.get_index(v1)].get_x();
|
|
|
|
|
double dy = graph.get_head()[graph.get_index(v2)].get_y();
|
|
|
|
|
double sy = graph.get_head()[graph.get_index(v1)].get_y();
|
|
|
|
|
double weight = (double)sqrt(((dx - sx) * (dx - sy) + (dy - sy) * (dy - sy)) / 30000.0) * 300.0;
|
|
|
|
|
int retop = graph.insert_edge(graph.get_index(v1), graph.get_index(v2), weight);
|
|
|
|
|
if (retop == -3) { ::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>", MB_OK); return -3; }
|
|
|
|
|
if (retop == -4) { ::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD>ڣ<EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>", MB_OK); return -4; }
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>", MB_OK);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int delete_vertex(Graph_List& graph) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
char v[10];
|
|
|
|
|
int v1;
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(v[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = str_to_num(v);
|
|
|
|
|
if (graph.get_index(v1) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD>˴<EFBFBD><EFBFBD>Ų<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
graph.delete_vertex(graph.get_index(v1));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int delete_path(Graph_List& graph) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
int v1, v2;
|
|
|
|
|
std::string source = "0000000000", destination = "0000000000";
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(source[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = str_to_num(source);
|
|
|
|
|
if (graph.get_index(v1) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(destination[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v2 = str_to_num(destination);
|
|
|
|
|
if (graph.get_index(v2) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
int retop = graph.delete_edge(graph.get_index(v1), graph.get_index(v2));
|
|
|
|
|
if (retop == -1) { ::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK); return -1; }
|
|
|
|
|
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", (LPCTSTR)"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
int draw_shortest_path(Graph_List& graph, int v1, int v2) {
|
|
|
|
|
Vertex* Head = graph.get_head();
|
|
|
|
|
|
|
|
|
|
int* path = new int[graph.number_of_vertices()];
|
|
|
|
|
graph.dshortest_path(v1, path);
|
|
|
|
|
Stack<int> s;
|
|
|
|
|
if (path[v2] == -1) {
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"*** <20><>·<EFBFBD><C2B7> ***", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
int i = v2;
|
|
|
|
|
while (i != path[v1]) {
|
|
|
|
|
s.push(i);
|
|
|
|
|
i = path[i];
|
|
|
|
|
}
|
|
|
|
|
delete[]path;
|
|
|
|
|
|
|
|
|
|
int temp = v1, temppre = v1, length = 0;
|
|
|
|
|
std::string pathstr, tempstr;
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
BeginBatchDraw();
|
|
|
|
|
while (!s.empty()) {
|
|
|
|
|
temp = s.peek();
|
|
|
|
|
s.pop();
|
|
|
|
|
// <20><>ʾ·<CABE><C2B7>
|
|
|
|
|
printroad(Head[temppre].get_x(), Head[temppre].get_y(), Head[temp].get_x(), Head[temp].get_y());
|
|
|
|
|
int path_weight = graph.get_weight(temppre, temp);
|
|
|
|
|
length += path_weight;
|
|
|
|
|
tempstr = tempstr + "<EFBFBD><EFBFBD>" + int_to_str(Head[temppre].get_mark()) + "<EFBFBD><EFBFBD>" + int_to_str(Head[temp].get_mark()) + "<EFBFBD><EFBFBD>" + int_to_str(path_weight) + "<EFBFBD><EFBFBD>\n";
|
|
|
|
|
temppre = temp;
|
|
|
|
|
}
|
|
|
|
|
FlushBatchDraw();
|
|
|
|
|
setbkcolor(BKCOLOR);
|
|
|
|
|
settextcolor(TEXTCOLOR);
|
|
|
|
|
std::string str = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>";
|
|
|
|
|
str = str + int_to_str(length) + " <20><>\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣺" + int_to_str(length / 90) + "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n";
|
|
|
|
|
str += tempstr;
|
|
|
|
|
::MessageBox(GetHWnd(), LPTSTR(&str[0]), (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
int find_path(Graph_List& graph) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
int v1, v2;
|
|
|
|
|
std::string source = "0000000000", destination = "0000000000";
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(source[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = str_to_num(source);
|
|
|
|
|
if (graph.get_index(v1) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(destination[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v2 = str_to_num(destination);
|
|
|
|
|
if (graph.get_index(v2) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
draw_shortest_path(graph, graph.get_index(v1), graph.get_index(v2));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>·<EEB3A4><C2B7>
|
|
|
|
|
int draw_longest_path(Graph_List& graph, int v1, int v2) {
|
|
|
|
|
Vertex* Head = graph.get_head();
|
|
|
|
|
|
|
|
|
|
int* path = new int[graph.number_of_vertices()];
|
|
|
|
|
graph.dlongest_path(v1, path);
|
|
|
|
|
Stack<int> s;
|
|
|
|
|
if (path[v2] == -1) {
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"*** <20><>·<EFBFBD><C2B7> ***", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
int i = v2;
|
|
|
|
|
while (i != path[v1]) {
|
|
|
|
|
s.push(i);
|
|
|
|
|
i = path[i];
|
|
|
|
|
}
|
|
|
|
|
delete[] path;
|
|
|
|
|
|
|
|
|
|
int temp = v1, temppre = v1, length = 0;
|
|
|
|
|
std::string pathstr, tempstr;
|
|
|
|
|
BeginBatchDraw();// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
while (!s.empty()) {
|
|
|
|
|
temp = s.peek();
|
|
|
|
|
s.pop();
|
|
|
|
|
printroad(Head[temppre].get_x(), Head[temppre].get_y(), Head[temp].get_x(), Head[temp].get_y());//<2F><>ʾ·<CABE><C2B7>
|
|
|
|
|
int pathweight = graph.get_weight(temppre, temp);
|
|
|
|
|
length += pathweight;
|
|
|
|
|
tempstr = tempstr + "<EFBFBD><EFBFBD>" + int_to_str(Head[temppre].get_mark()) + "<EFBFBD><EFBFBD>" + int_to_str(Head[temp].get_mark()) + " : " + int_to_str(pathweight) + " <20><>" + "\n";
|
|
|
|
|
temppre = temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FlushBatchDraw();// ִ<><D6B4>δ<EFBFBD><CEB4><EFBFBD>ɵĻ<C9B5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
setbkcolor(BKCOLOR);// <20><>ʾ<EFBFBD><CABE>ɫ
|
|
|
|
|
settextcolor(TEXTCOLOR);//<2F><>ʾ<EFBFBD><CABE>ɫ
|
|
|
|
|
std::string str = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>";
|
|
|
|
|
str = str + int_to_str(length) + " <20><>\n" + "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣺" + int_to_str(length / 90) + "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n";
|
|
|
|
|
str += tempstr;
|
|
|
|
|
::MessageBox(GetHWnd(), LPTSTR(&str[0]), (LPCTSTR)"<EFBFBD><EFBFBD>ѯ·<EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
int wandering(Graph_List& grpah) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
int v1, v2;
|
|
|
|
|
std::string source = "0000000000", destination = "0000000000";
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(source[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = str_to_num(source);
|
|
|
|
|
if (graph.get_index(v1) == -1) ::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ", MB_OK);
|
|
|
|
|
else break;
|
|
|
|
|
}
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(destination[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v2 = str_to_num(destination);
|
|
|
|
|
if (graph.get_index(v1) == -1) ::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ", MB_OK);
|
|
|
|
|
else break;
|
|
|
|
|
}
|
|
|
|
|
draw_longest_path(graph, graph.get_index(v1), graph.get_index(v2));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void show_vertex(Graph_List& graph, int i) {
|
|
|
|
|
Vertex* Head = graph.get_head();
|
|
|
|
|
if (i < 0 || i > graph.number_of_vertices() - 1) {
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>ѯλ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ", MB_OK); //GetHWnd()<29><><EFBFBD>ô<EFBFBD><C3B4>ھ<EFBFBD><DABE><EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::string str = "<EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>" + int_to_str(Head[i].get_mark()) + "\n" + "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: " + Head[i].get_Description();
|
|
|
|
|
str = "<EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>" + Head[i].get_VerName() + "\n" + str;
|
|
|
|
|
::MessageBox(GetHWnd(), LPTSTR(&str[0]), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ", MB_OK); //GetHWnd()<29><><EFBFBD>ô<EFBFBD><C3B4>ھ<EFBFBD><DABE><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>IJ˵<C4B2>
|
|
|
|
|
|
|
|
|
|
int ModifyMenu() {
|
|
|
|
|
int choose1 = 1;
|
|
|
|
|
char temp = 0, key;
|
|
|
|
|
while (temp != '\r') {
|
|
|
|
|
if (_kbhit()) {
|
|
|
|
|
key = _getch(); // <20><>ȡ<EFBFBD>ַ<EFBFBD>
|
|
|
|
|
fflush(stdin); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
switch (key) {
|
|
|
|
|
case UP: choose1--; break;
|
|
|
|
|
case DOWN: choose1++; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (choose1 == 6) choose1 = 5;
|
|
|
|
|
if (choose1 == 0) choose1 = 1;
|
|
|
|
|
IMAGE img;
|
|
|
|
|
loadimage(&img, (LPCTSTR)"R-C.jpg", WIDTH, HEIGHT);
|
|
|
|
|
cleardevice();
|
|
|
|
|
putimage(0, 0, &img);
|
|
|
|
|
// transparentimage3(NULL, 0, 0, &img);
|
|
|
|
|
outtextxy((WIDTH / 2) - 80, 120, (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy((WIDTH / 2) - 180, 230, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>ѡ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy((WIDTH / 2) - 180, 250, (LPCTSTR)"<EFBFBD><EFBFBD>ENTER<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(300, 300, (LPCTSTR)"<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ѡ<EFBFBD>");
|
|
|
|
|
outtextxy(420, 350, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(420, 380, (LPCTSTR)"<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(420, 410, (LPCTSTR)"<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(420, 440, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(420, 470, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(390, 350 + (choose1 - 1) * 30, (LPCTSTR)"<EFBFBD><EFBFBD>");
|
|
|
|
|
FlushBatchDraw();// ִ<><D6B4>δ<EFBFBD><CEB4><EFBFBD>ɵĻ<C9B5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
temp = _getch();
|
|
|
|
|
}
|
|
|
|
|
return choose1;
|
|
|
|
|
}
|
|
|
|
|
// <20>ľ<DEB8><C4BE><EFBFBD>
|
|
|
|
|
int modify_vertex(Graph_List& graph) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
int v1;
|
|
|
|
|
char v1str[10] = { 'a' };
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(v1str[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = str_to_num(v1str);
|
|
|
|
|
if (graph.get_index(v1) != -1) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
int v = graph.get_index(v1);
|
|
|
|
|
Vertex* Head = graph.get_head();
|
|
|
|
|
std::string name = Head[v].get_VerName();
|
|
|
|
|
std::string description = Head[v].get_Description();
|
|
|
|
|
int marki = Head[v].get_mark();
|
|
|
|
|
int x = Head[v].get_x();
|
|
|
|
|
int y = Head[v].get_y();
|
|
|
|
|
bool is_return = false;
|
|
|
|
|
while (!is_return) {
|
|
|
|
|
int in = ModifyMenu();
|
|
|
|
|
switch (in) {
|
|
|
|
|
case 1: {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(name[0])), 30, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(description[0])), 1000, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飺(<28><>Ctrl+Enterȷ<72><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 10, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: {
|
|
|
|
|
char mark[10];
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(mark[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", 0, 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
marki = str_to_num(mark);
|
|
|
|
|
if (marki > 0 && (marki == Head[v].get_mark() || graph.get_index(marki) == -1)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 4: {
|
|
|
|
|
char xstr[10], ystr[10];
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(xstr[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
x = str_to_num(xstr);
|
|
|
|
|
if (x > 0 && x < WIDTH) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>겻<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(ystr[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
y = str_to_num(ystr);
|
|
|
|
|
if (y > 0 && y < HEIGHT) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>겻<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 5: {
|
|
|
|
|
graph.modify_vertex(v, name, description, marki, x, y);
|
|
|
|
|
show_vertex(graph, v);
|
|
|
|
|
is_return = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ʾ<EFBFBD>ڵ<EFBFBD>
|
|
|
|
|
int show_all_vertex(Graph_List& graph) {
|
|
|
|
|
Vertex* Head = graph.get_head();
|
|
|
|
|
setbkcolor(RGB(240, 240, 240));
|
|
|
|
|
settextcolor(RED);
|
|
|
|
|
setfillcolor(RGB(255, 0, 0));
|
|
|
|
|
LOGFONT font1;
|
|
|
|
|
gettextstyle(&font1);
|
|
|
|
|
settextstyle(font1.lfHeight - 2, 0, _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|
|
|
|
for (int i = 0; i < graph.number_of_vertices(); i++) {
|
|
|
|
|
int x = Head[i].get_x(), y = Head[i].get_y();
|
|
|
|
|
std::string str = "";
|
|
|
|
|
str += int_to_str(Head[i].get_mark()); // <20>ڵ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
if (Head[i].get_VerName() != "*") str = str + " " + Head[i].get_VerName();
|
|
|
|
|
solidcircle(x, y, 4); // <20><>ʾ<EFBFBD>ڵ<EFBFBD>
|
|
|
|
|
outtextxy(x, y, (LPCTSTR)&str[0]); // <20><><EFBFBD><EFBFBD>str<74>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
settextstyle(&font1);
|
|
|
|
|
FlushBatchDraw();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int show_all_path(Graph_List& graph) {
|
|
|
|
|
LINESTYLE linestyle;
|
|
|
|
|
getlinestyle(&linestyle);
|
|
|
|
|
setlinestyle(PS_SOLID, 3, NULL, 0);
|
|
|
|
|
setlinecolor(BLUE);
|
|
|
|
|
for (int i = 0; i < graph.number_of_vertices(); i++) {
|
|
|
|
|
Edge* p = graph.get_head()[i].get_adjacent();
|
|
|
|
|
while (p) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽڵ<DABD><DAB5>ı<EFBFBD>
|
|
|
|
|
line(graph.get_head()[i].get_x(), graph.get_head()[i].get_y(),
|
|
|
|
|
graph.get_head()[p->get_VerAdj()].get_x(),
|
|
|
|
|
graph.get_head()[p->get_VerAdj()].get_y());
|
|
|
|
|
p = p->get_link(); // ָ<><D6B8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ڱ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|
|
|
|
setlinestyle(&linestyle);
|
|
|
|
|
FlushBatchDraw();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
int find_menu() {
|
|
|
|
|
int choose1 = 1;
|
|
|
|
|
char temp = 0, key;
|
|
|
|
|
while (temp != '\r') {
|
|
|
|
|
if (_kbhit()) {
|
|
|
|
|
key = _getch();
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
switch (key) {
|
|
|
|
|
case UP: {
|
|
|
|
|
choose1--;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case DOWN: {
|
|
|
|
|
choose1++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (choose1 == 4) choose1 = 3;
|
|
|
|
|
if (choose1 == 0) choose1 = 1;
|
|
|
|
|
cleardevice();
|
|
|
|
|
IMAGE img;
|
|
|
|
|
loadimage(&img, (LPCTSTR)"R-C.jpg", WIDTH, HEIGHT);
|
|
|
|
|
putimage(0, 0, &img);
|
|
|
|
|
outtextxy((WIDTH / 2) - 80, 120, (LPCTSTR)"<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");//<2F><>ָ<EFBFBD><D6B8>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
outtextxy((WIDTH / 2) - 180, 230, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>ѡ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy((WIDTH / 2) - 180, 250, (LPCTSTR)"<EFBFBD><EFBFBD>ENTER<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(300, 300, (LPCTSTR)"<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ѡ<EFBFBD>");
|
|
|
|
|
outtextxy(420, 350, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD>ѯ");
|
|
|
|
|
outtextxy(420, 380, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD>ѯ");
|
|
|
|
|
outtextxy(420, 410, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(390, 350 + (choose1 - 1) * 30, (LPCTSTR)"<EFBFBD><EFBFBD>");
|
|
|
|
|
FlushBatchDraw();
|
|
|
|
|
temp = _getch();
|
|
|
|
|
}
|
|
|
|
|
return choose1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>Ҿ<EFBFBD><D2BE><EFBFBD>
|
|
|
|
|
int find_vertex(Graph_List& graph) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
bool is_return = false;
|
|
|
|
|
while (!is_return) {
|
|
|
|
|
int in = find_menu();
|
|
|
|
|
switch (in) {
|
|
|
|
|
case 1: {
|
|
|
|
|
char v1str[10] = { 'a' };
|
|
|
|
|
int v1;
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(v1str[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = str_to_num(v1str);
|
|
|
|
|
show_vertex(graph, graph.get_index(v1));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: {
|
|
|
|
|
char v1str[10] = { 'a' };
|
|
|
|
|
std::string v1;
|
|
|
|
|
is_cancel = !InputBox(LPTSTR(&(v1str[0])), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
v1 = "";
|
|
|
|
|
v1 += v1str;
|
|
|
|
|
show_vertex(graph, graph.get_index(v1));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: {
|
|
|
|
|
is_return = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: {} break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
int open(Graph_List& graph, bool is_first_open) {
|
|
|
|
|
std::fstream filestr;
|
|
|
|
|
char mapname[256] = { 'a' }; // map_name<6D><65><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|
|
|
|
if (is_first_open) {
|
|
|
|
|
filestr.open("map.txt");
|
|
|
|
|
strcpy_s(mapname, "seu map.png");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
char filename[256] = { 'a' };
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox((LPTSTR) & (filename[0]), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'.txt')", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
strcat_s(filename, ".txt");
|
|
|
|
|
filestr.open(filename);
|
|
|
|
|
if (filestr.is_open()) break;
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK); //<2F><>ʾ<EFBFBD><CABE>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
while (true) {
|
|
|
|
|
is_cancel = !InputBox((LPTSTR) & (mapname[0]), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'.png')", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
strcat_s(mapname, ".png");
|
|
|
|
|
if ((_access(mapname, 0)) != -1) { //_access,<2C>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB>߲<EFBFBD><DFB2>ܷ<EFBFBD><DCB7><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD>-1.
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ڵ<EFBFBD><DAB5>ͱ<EFBFBD><CDB1><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ͼ
|
|
|
|
|
graph.graph_con(filestr, mapname);
|
|
|
|
|
filestr.close();
|
|
|
|
|
putimage(LEFTBORDER, TOPBORDER, graph.get_map());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
int save(Graph_List& graph) {
|
|
|
|
|
bool is_cancel = false;
|
|
|
|
|
Vertex* head = graph.get_head();
|
|
|
|
|
char filename[256] = { 'a' };
|
|
|
|
|
is_cancel = !InputBox((LPTSTR) & (filename[0]), 10, (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'.txt')", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"0", 0, 0, 0);
|
|
|
|
|
CheckCancel;
|
|
|
|
|
strcat_s(filename, ".txt");
|
|
|
|
|
graph.save_file(filename);
|
|
|
|
|
::MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int get_choose() {
|
|
|
|
|
FlushMouseMsgBuffer(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
MOUSEMSG temp;
|
|
|
|
|
temp.mkLButton = false;
|
|
|
|
|
bool kick = false;
|
|
|
|
|
while (!kick) {
|
|
|
|
|
temp = GetMouseMsg(); // <20><>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>
|
|
|
|
|
FlushMouseMsgBuffer();
|
|
|
|
|
if (temp.mkLButton == false) {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (temp.y < menu_top + menu_height && temp.y > menu_top) kick = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
choose = (temp.x - left) / menu_width;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
// <20>˵<EFBFBD>
|
|
|
|
|
int front_menu(Graph_List& graph) {
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
settextcolor(TEXTCOLOR);
|
|
|
|
|
setfillcolor(BKCOLOR);
|
|
|
|
|
solidrectangle(5, TOPBORDER, WIDTH, HEIGHT); //<2F>Ա<EFBFBD><D4B1><EFBFBD>ɫˢ<C9AB><CBA2>
|
|
|
|
|
setfillcolor(MENUCOLOR);
|
|
|
|
|
solidrectangle(5, 0, WIDTH - 5, menu_top1); //<2F><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
|
|
|
|
|
putimage(LEFTBORDER, TOPBORDER, graph.get_map());
|
|
|
|
|
setfillcolor(BKCOLOR);
|
|
|
|
|
solidrectangle(LEFTBORDER, menu_top + textheight('a'), WIDTH - LEFTBORDER, menu_top + textheight('a') + 5); //ȥ<><C8A5>ѡ<EFBFBD>еIJ˵<C4B2><CBB5>·<EFBFBD><C2B7><EFBFBD>С<EFBFBD>̿<EFBFBD>
|
|
|
|
|
setfillcolor(TEXTCOLOR);
|
|
|
|
|
setfillcolor(MENUCOLOR);
|
|
|
|
|
solidrectangle(choose * menu_width + left, menu_top + textheight('a'),
|
|
|
|
|
(choose + 1) * menu_width + left, menu_top + textheight('a') + 5); //<2F><>ѡ<EFBFBD>еIJ˵<C4B2><CBB5>·<EFBFBD><C2B7><EFBFBD>С<EFBFBD>̿<EFBFBD>
|
|
|
|
|
roundrect(5, menu_top + textheight('a') + 5, WIDTH - 5, HEIGHT - 5, 5, 3); //<2F><>ͼƬ<CDBC><C6AC>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>ɫ<EFBFBD>߿<EFBFBD>
|
|
|
|
|
solidrectangle(5, menu_top + textheight('a') + 5, WIDTH - 5, menu_top + textheight('a') + 10); //<2F><>ͼƬ<CDBC>Ϸ<EFBFBD><CFB7><EFBFBD>С<EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
|
|
|
|
|
setfillcolor(TEXTCOLOR);
|
|
|
|
|
LOGFONT font1;
|
|
|
|
|
gettextstyle(&font1);
|
|
|
|
|
settextstyle(font1.lfHeight, 0, _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|
|
|
|
std::string menu[menu_num] = { " <20><><EFBFBD><EFBFBD>", " <20><>ʾ", " <20><>ѯ·<D1AF><C2B7>",
|
|
|
|
|
" <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>", " <20>ľ<DEB8><C4BE><EFBFBD>", " <20><><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD>", " ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
" <20><><EFBFBD>ӱ<EFBFBD>", " ɾ<><C9BE><EFBFBD><EFBFBD>"," <20><><EFBFBD><EFBFBD>", " <20>˳<EFBFBD>"};//<2F>˵<EFBFBD><CBB5><EFBFBD>
|
|
|
|
|
for (int index = 0; index <= menu_num - 1; index++) {
|
|
|
|
|
if (index == choose)settextcolor(SELECTCOLOR);
|
|
|
|
|
const char* p = menu[index].c_str();
|
|
|
|
|
outtextxy(left + index * menu_width, menu_top, (LPCTSTR)p);
|
|
|
|
|
if (index == choose)settextcolor(TEXTCOLOR);
|
|
|
|
|
}
|
|
|
|
|
settextstyle(&font1);
|
|
|
|
|
setlinecolor(MENUCOLOR);
|
|
|
|
|
for (int index1 = 0; index1 <= menu_num + 1; index1++) {
|
|
|
|
|
line(left + index1 * menu_width, menu_top, left + index1 * menu_width, menu_top + textheight('a'));
|
|
|
|
|
}
|
|
|
|
|
LOGFONT font;
|
|
|
|
|
gettextstyle(&font);
|
|
|
|
|
settextstyle(10, 0, _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|
|
|
|
settextcolor(TEXTCOLOR);
|
|
|
|
|
for (int lx = LEFTBORDER; lx <= WIDTH; lx += 50) {
|
|
|
|
|
outtextxy(lx, TOPBORDER - 10, (LPCTSTR)&int_to_str(lx - LEFTBORDER)[0]);
|
|
|
|
|
}
|
|
|
|
|
for (int ly = TOPBORDER; ly <= HEIGHT - LEFTBORDER; ly += 50) {
|
|
|
|
|
outtextxy(10, ly - 5, (LPCTSTR)&int_to_str(ly - TOPBORDER)[0]);
|
|
|
|
|
}
|
|
|
|
|
settextstyle(&font);
|
|
|
|
|
settextcolor(TEXTCOLOR);
|
|
|
|
|
FlushBatchDraw();
|
|
|
|
|
setbkcolor(BKCOLOR);
|
|
|
|
|
settextcolor(TEXTCOLOR);
|
|
|
|
|
return choose;
|
|
|
|
|
}
|
|
|
|
|
void on_btnOK_click() {
|
|
|
|
|
if (wcscmp(L"123", txt_password.get_text())) {
|
|
|
|
|
MessageBox(GetHWnd(), (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", (LPCTSTR)"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wchar_t s[100] = L"Hello, ";
|
|
|
|
|
wcscat_s(s, 100, txt_name.get_text());
|
|
|
|
|
MessageBox(GetHWnd(), (LPCTSTR)s, (LPCTSTR)"<EFBFBD><EFBFBD>½<EFBFBD>ɹ<EFBFBD>", MB_OK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//void log_in() {
|
|
|
|
|
// initgraph(640, 480);
|
|
|
|
|
// setbkcolor(0xeeeeee);
|
|
|
|
|
// cleardevice();
|
|
|
|
|
// settextcolor(BLACK);
|
|
|
|
|
// outtextxy(50, 55, (LPCTSTR)"<22>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
// txt_name.create(120, 50, 400, 75, 10);
|
|
|
|
|
// outtextxy(50, 105, (LPCTSTR)"<22><> <20>룺");
|
|
|
|
|
// txt_password.create(120, 100, 400, 125, 10);
|
|
|
|
|
// btnOK.create(320, 150, 400, 175, L"OK", on_btnOK_click);
|
|
|
|
|
//
|
|
|
|
|
// ExMessage msg;
|
|
|
|
|
// while (true) {
|
|
|
|
|
// msg = getmessage(EX_MOUSE); // <20><>ȡ<EFBFBD><C8A1>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|
|
|
|
// if (msg.message == WM_LBUTTONDOWN) {
|
|
|
|
|
// // <20>жϿؼ<CFBF>
|
|
|
|
|
// if (txt_name.check(msg.x, msg.y)) txt_name.on_message();
|
|
|
|
|
// if (txt_password.check(msg.x, msg.y)) txt_password.on_message();
|
|
|
|
|
// if (btnOK.check(msg.x, msg.y)) btnOK.on_message();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // <20>رմ<D8B1><D5B4><EFBFBD>
|
|
|
|
|
// closegraph();
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
// log_in();
|
|
|
|
|
|
|
|
|
|
initgraph(WIDTH, HEIGHT);
|
|
|
|
|
setbkcolor(BKCOLOR);
|
|
|
|
|
cleardevice();
|
|
|
|
|
log_in_2(account);
|
|
|
|
|
bool is_first_open = true;
|
|
|
|
|
while (true) {
|
|
|
|
|
front_menu(graph);
|
|
|
|
|
if (is_first_open) choose = 0;
|
|
|
|
|
else get_choose();
|
|
|
|
|
front_menu(graph);
|
|
|
|
|
switch (choose) {
|
|
|
|
|
case 0: {
|
|
|
|
|
open(graph, is_first_open);
|
|
|
|
|
is_first_open = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1: {
|
|
|
|
|
show_all_path(graph);
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
int vertex_num = graph.number_of_vertices();
|
|
|
|
|
int edge_num = graph.number_of_edges();
|
|
|
|
|
std::string num_of_vertices;
|
|
|
|
|
num_of_vertices = "ͼ<EFBFBD>й<EFBFBD><EFBFBD>о<EFBFBD><EFBFBD><EFBFBD> " + int_to_str(vertex_num) + "<EFBFBD><EFBFBD>\n" + "<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>" + int_to_str(edge_num) + "<EFBFBD><EFBFBD>\n";
|
|
|
|
|
::MessageBox(GetHWnd(), LPCSTR(&num_of_vertices[0]), (LPCSTR)"<EFBFBD><EFBFBD>ʾ", MB_OK);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: {
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
find_path(graph);
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//case 3: {
|
|
|
|
|
// // std::cout << 1 << std::endl;
|
|
|
|
|
// show_all_vertex(graph);
|
|
|
|
|
// wandering(graph);
|
|
|
|
|
// show_all_vertex(graph);
|
|
|
|
|
// break;
|
|
|
|
|
//}
|
|
|
|
|
case 3: {
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
find_vertex(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 4: {
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
modify_vertex(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 5: {
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
add_vertex(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 6: {
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
delete_vertex(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 7: {
|
|
|
|
|
show_all_path(graph);
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
add_path(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 8: {
|
|
|
|
|
show_all_path(graph);
|
|
|
|
|
show_all_vertex(graph);
|
|
|
|
|
delete_path(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 9: {
|
|
|
|
|
save(graph);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 10: {
|
|
|
|
|
WinExec((LPCSTR)_T("taskkill /f /im conhost.ext /t"), 1);
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|