项目下载地址:
听说点赞后食用效果更好哟
链接: https://pan.baidu.com/s/1XjdTepiPZKeng8v8lSsuOA?pwd=gvp5 提取码: gvp5
代码介绍:
本代码基于1.0升级,是在visual studio中自带的easyx图形库进行实现的,因为做的时候时间较紧,只敲了一天半,同时不太熟悉visual studio软件,就没有进行模块化处理,但相比1.0还是有可观的升级和可参考性,因为本代码可以插入图片和用鼠标操作,所以有一些创新的地方
代码中所有的图片地址同时也需要更改为个人电脑中存储的图片的地址
具体效果
代码实现
#include<iostream>
using namespace std;
#include<string.h>
#include<graphics.h>
#include<easyx.h>
#define INF 0x3f3f3f3f
const int N = 20;
int ditu[N][N] = { 0 };
int push[N][N] = { 0 };
struct jingdian {
int bianhao;
char jingdian_name[10];
}jq[N];
void jingdianchaxun();
void ditucha();
void shubiao4();
void zuiduanlu();
void shubiao1();
void shubiao2();
void jiemian2();
void jiemian1();
void geshihua() {
for (int i = 0; i <= 11; i++) {
jq[i].bianhao = i;
if (i == 1) {
strcpy(jq[i].jingdian_name, "健身房");
}
else if (i == 2) {
strcpy(jq[i].jingdian_name, "教学区");
}
else if (i == 3) {
strcpy(jq[i].jingdian_name, "龙井湖");
}
else if (i == 4) {
strcpy(jq[i].jingdian_name, "情人岛");
}
else if (i == 5) {
strcpy(jq[i].jingdian_name, "生活区");
}
else if (i == 6) {
strcpy(jq[i].jingdian_name, "石油魂");
}
else if (i == 7) {
strcpy(jq[i].jingdian_name, "体育馆");
}
else if (i == 8) {
strcpy(jq[i].jingdian_name, "图书馆");
}
else if (i == 9) {
strcpy(jq[i].jingdian_name, "校医院");
}
else if (i == 10) {
strcpy(jq[i].jingdian_name, "龙井苑");
}
else if (i == 11) {
strcpy(jq[i].jingdian_name, "教职工区域");
}
else if (i == 0) {
strcpy(jq[i].jingdian_name, "西大门");
}
}
}
void geshi() {
for (int i = 0; i <= 11; i++)
for (int j = 0; j <= 11; j++) {
ditu[i][j] = INF;
}
ditu[0][7] = 36;
ditu[0][9] = 42;
ditu[9][2] = 58;
ditu[9][11] = 124;
ditu[0][6] = 52;
ditu[6][0] = 52;
ditu[6][2] = 78;
ditu[2][6] = 78;
ditu[7][5] = 35;
ditu[5][7] = 35;
ditu[5][4] = 66;
ditu[4][10] = 68;
ditu[10][4] = 68;
ditu[4][6] = 65;
ditu[5][8] = 72;
ditu[8][1] = 55;
ditu[8][2] = 34;
ditu[2][1] = 53;
ditu[3][4] = 0;
ditu[4][3] = 0;
}
void floyd() {
int i, j, k;
for (i = 0; i <= 11; i++)
for (j = 0; j <= 11; j++)
{
if (i != j && ditu[i][j] < INF) {
push[i][j] = i;
}
else
push[i][j] = -1;
}
for (k = 0; k <= 11; k++)
for (i = 0; i <= 11; i++)
for (j = 0; j <= 11; j++) {
if (ditu[i][j] > ditu[i][k] + ditu[k][j]) {
ditu[i][j] = ditu[i][k] + ditu[k][j];
push[i][j] = push[k][j];
}
}
}
void Path(int src, int des, int puth[N][N]) {
if (src == des) {
return;
}
else {
int pass = puth[src][des];
char dimi[10];
Path(src, pass, puth);
for (int i = 0; i <= 11; i++) {
if (jq[i].bianhao == pass) {
strcpy(dimi, jq[i].jingdian_name);
}
}
printf("%s-->", dimi);
}
}
void button(int x, int y, int w, int h, const char* text)
{
setbkmode(TRANSPARENT);
setfillcolor(rad10);
fillroundrect(x, y, x + w, y + h, 40, 40);
settextstyle(30, 0, "楷体");
char text_[255] = "欢迎来到西南石油大学";
strcpy_s(text_, text);
int tx = x + (w - textwidth(text)) / 2;
int ty = y + (h - textheight(text)) / 2;
outtextxy(tx, ty, text);
}
void shubiao7()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 10 && msg.y <= 10 + 30)
{
jiemian2();
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 50 && msg.y <= 50 + 30)
{
jiemian1();
}
default:
break;
}
}
}
}
void xiaoyuanditu()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./xiaoyuantidu.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao7();
}
void shubiao9()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 10 && msg.y <= 10 + 30)
{
cleardevice;
jingdianchaxun();
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 50 && msg.y <= 50 + 30)
{
cleardevice();
jiemian1();
}
default:
break;
}
}
}
}
void wenjian1()
{
FILE* fp;
char buff[600];
fp = fopen("./西门.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian1()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./西大门.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian2()
{
FILE* fp;
char buff[600];
fp = fopen("./石油魂.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian2()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./石油魂2.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian3()
{
FILE* fp;
char buff[600];
fp = fopen("./校医院.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian3()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./校医院.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian4()
{
FILE* fp;
char buff[600];
fp = fopen("./教职工区域.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian4()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./教职工生活区.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian5()
{
FILE* fp;
char buff[600];
fp = fopen("./图书馆.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian5()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./图书馆.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian6()
{
FILE* fp;
char buff[600];
fp = fopen("./生活区.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian6()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./食堂.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian7()
{
FILE* fp;
char buff[600];
fp = fopen("./体育馆.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian7()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./体育馆2.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian8()
{
FILE* fp;
char buff[600];
fp = fopen("./龙井湖.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian8()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./龙井湖1.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian9()
{
FILE* fp;
char buff[600];
fp = fopen("./情人岛.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian9()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./情人岛1.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian10()
{
FILE* fp;
char buff[600];
fp = fopen("./龙井苑.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian10()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./龙井苑.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void wenjian11()
{
FILE* fp;
char buff[600];
fp = fopen("./健身房.txt", "r");
while (fgets(buff, 600, (FILE*)fp))
printf("%s\n", buff);
fclose(fp);
}
void tupian11()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./健身房.jpg");
putimage(0, 0, &img);
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao9();
}
void xuanzhe1()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian1();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian1();
}
default:
break;
}
}
}
}
void xuanzhe2()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian2();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian2();
}
default:
break;
}
}
}
}
void xuanzhe3()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian3();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian3();
}
default:
break;
}
}
}
}
void xuanzhe4()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian4();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian4();
}
default:
break;
}
}
}
}
void xuanzhe5()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian5();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian5();
}
default:
break;
}
}
}
}
void xuanzhe6()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian6();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian6();
}
default:
break;
}
}
}
}
void xuanzhe7()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian7();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian7();
}
default:
break;
}
}
}
}
void xuanzhe8()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian8();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian8();
}
default:
break;
}
}
}
}
void xuanzhe9()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian9();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian9();
}
default:
break;
}
}
}
}
void xuanzhe10()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian10();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian10();
}
default:
break;
}
}
}
}
void xuanzhe11()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 200 && msg.y <= 200 + 30)
{
wenjian11();
}
else if (msg.x >= 400 && msg.x <= 400 + 200 && msg.y >= 300 && msg.y <= 300 + 30)
{
tupian11();
}
default:
break;
}
}
}
}
void shubiao8()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 30 && msg.x <= 30 + 150 && msg.y >= 530 && msg.y <= 530 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe1();
}
else if (msg.x >= 200 && msg.x <= 200 + 150 && msg.y >= 530 && msg.y <= 530 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe2();
}
else if (msg.x >= 100 && msg.x <= 250 && msg.y >= 650 && msg.y <= 650 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe3();
}
else if (msg.x >= 250 && msg.x <= 500 && msg.y >= 600 && msg.y <= 600 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe4();
}
else if (msg.x >= 720 && msg.x <= 870 && msg.y >= 380 && msg.y <= 380 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe5();
}
else if (msg.x >= 230 && msg.x <= 580 && msg.y >= 100 && msg.y <= 100 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe6();
}
else if (msg.x >= 180 && msg.x <= 330 && msg.y >= 250 && msg.y <= 250 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe7();
}
else if (msg.x >= 350 && msg.x <= 500 && msg.y >= 300 && msg.y <= 300 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe8();
}
else if (msg.x >= 450 && msg.x <= 600 && msg.y >= 320 && msg.y <= 320 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe9();
}
else if (msg.x >= 500 && msg.x <= 650 && msg.y >= 400 && msg.y <= 600 + 30)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe10();
}
else if (msg.x >= 880 && msg.x <= 1030 && msg.y >= 500 && msg.y <= 500 + 30)
{
initgraph(1080, 729, EW_SHOWCONSOLE);
cleardevice();
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
button(400, 200, 200, 30, "地点信息");
button(400, 300, 200, 30, "图片查询");
xuanzhe11();
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 10 && msg.y <= 10 + 30)
{
cleardevice;
jiemian2();
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 50 && msg.y <= 50 + 30)
{
cleardevice();
jiemian1();
}
default:
break;
}
}
}
}
void jingdianchaxun()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./xiaoyuantidu.jpg");
putimage(0, 0, &img);
button(30, 530, 150, 30, "0.西大门");
button(200, 530, 150, 30, "6.石油魂");
button(100, 650, 150, 30, "9.校医院");
button(250, 600, 250, 30, "11.教职工区域");
button(720, 380, 150, 30, "8.图书馆");
button(230, 100, 350, 30, "5.生活区");
button(180, 250, 150, 30, "7.体育馆");
button(350, 300, 150, 30, "3.龙井湖");
button(450, 320, 150, 30, "4.情人岛");
button(500, 400, 150, 30, "10.龙井苑");
button(880, 500, 150, 30, "1.健身房");
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao8();
}
void biaohaocha1(int a,int b)
{
printf("\t\t\n");
printf("%d地点到%d地点最短路径长度为: ", a, b);
printf("%d\n", ditu[a][b]);
printf("%d地点到%d地点经过路程地点为: ", a, b);
Path(a, b, push);
printf("%s\n", jq[b].jingdian_name);
}
void prin(int a, int b)
{
printf("\t\t\n");
printf("%d地点到%d地点最短路径长度为: ", a, b);
printf("%d\n", ditu[a][b]);
printf("%d地点到%d地点经过路程地点为: ", a, b);
Path(a, b, push);
printf("%s\n", jq[b].jingdian_name);
}
void shubiao5(int a)
{
int b = -1;
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 30 && msg.x <= 30 + 150 && msg.y >= 530 && msg.y <= 530 + 30)
{
b = 0;
prin(a, b);
}
else if (msg.x >= 200 && msg.x <= 200 + 150 && msg.y >= 530 && msg.y <= 530 + 30)
{
b = 6;
prin(a, b);
}
else if (msg.x >= 100 && msg.x <= 250 && msg.y >= 650 && msg.y <= 650 + 30)
{
b = 9;
prin(a, b);
}
else if (msg.x >= 250 && msg.x <= 500 && msg.y >= 600 && msg.y <= 600 + 30)
{
b = 11;
prin(a, b);
}
else if (msg.x >= 720 && msg.x <= 930 && msg.y >= 380 && msg.y <= 380 + 30)
{
b = 8;
prin(a, b);
}
else if (msg.x >= 230 && msg.x <= 580 && msg.y >= 100 && msg.y <= 100 + 30)
{
b = 5;
prin(a, b);
}
else if (msg.x >= 180 && msg.x <= 330 && msg.y >= 250 && msg.y <= 250 + 30)
{
b = 7;
prin(a, b);
}
else if (msg.x >= 350 && msg.x <= 500 && msg.y >= 300 && msg.y <= 300 + 30)
{
b = 3;
prin(a, b);
}
else if (msg.x >= 450 && msg.x <= 600 && msg.y >= 320 && msg.y <= 320 + 30)
{
b = 4;
prin(a, b);
}
else if (msg.x >= 500 && msg.x <= 650 && msg.y >= 400 && msg.y <= 600 + 30)
{
b = 10;
prin(a, b);
}
else if (msg.x >= 880 && msg.x <= 1030 && msg.y >= 500 && msg.y <= 500 + 30)
{
b = 1;
prin(a, b);
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 10 && msg.y <= 10 + 30)
{
system("cls");
zuiduanlu();
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 50 && msg.y <= 50 + 30)
{
system("cls");
jiemian1();
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 90 && msg.y <= 90 + 30)
{
system("cls");
ditucha();
}
default:
break;
}
}
}
}
void ditucha1(int a)
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./xiaoyuantidu.jpg");
putimage(0, 0, &img);
button(30, 530, 150, 30, "0.西大门");
button(200, 530, 150, 30, "6.石油魂");
button(100, 650, 150, 30, "9.校医院");
button(250, 600, 250, 30, "11.教职工区域");
button(720, 380, 150, 30, "8.图书馆");
button(230, 100, 350, 30, "5.生活区");
button(180, 250, 150, 30, "7.体育馆");
button(350, 300, 150, 30, "3.龙井湖");
button(450, 320, 150, 30, "4.情人岛");
button(500, 400, 150, 30, "10.龙井苑");
button(880, 500, 150, 30, "1.健身房");
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
button(850, 90, 200, 30, "更新出发点");
shubiao5(a);
}
void shubiao4()
{
int a = -1, b = -1;
ExMessage msg;
while(1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 30 && msg.x <= 30 + 150 && msg.y >= 530 && msg.y <= 530 + 30)
{
a = 0;
ditucha1(a);
}
else if (msg.x >= 200 && msg.x <= 200 + 150 && msg.y >= 530 && msg.y <= 530 + 30)
{
a = 6;
ditucha1(a);
}
else if (msg.x >= 100 && msg.x <= 250 && msg.y >= 650 && msg.y <= 650 + 30)
{
a = 9;
ditucha1(a);
}
else if (msg.x >= 250 && msg.x <= 500 && msg.y >= 600 && msg.y <= 600 + 30)
{
a = 11;
ditucha1(a);
}
else if (msg.x >= 720 && msg.x <= 870 && msg.y >= 380 && msg.y <= 380 + 30)
{
a = 8;
ditucha1(a);
}
else if (msg.x >= 230 && msg.x <= 580 && msg.y >= 100 && msg.y <= 100 + 30)
{
a = 5;
ditucha1(a);
}
else if (msg.x >= 180 && msg.x <= 330 && msg.y >= 250 && msg.y <= 250 + 30)
{
a = 7;
ditucha1(a);
}
else if (msg.x >= 350 && msg.x <= 500 && msg.y >= 300 && msg.y <= 300 + 30)
{
a = 3;
ditucha1(a);
}
else if (msg.x >= 450 && msg.x <= 600 && msg.y >= 320 && msg.y <= 320 + 30)
{
a = 4;
ditucha1(a);
}
else if (msg.x >= 500 && msg.x <= 650 && msg.y >= 400 && msg.y <= 600 + 30)
{
a = 10;
ditucha1(a);
}
else if (msg.x >= 880 && msg.x <= 1030 && msg.y >= 500 && msg.y <= 500 + 30)
{
a = 1;
ditucha1(a);
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 10 && msg.y <= 10 + 30)
{
system("cls");
zuiduanlu();
}
else if (msg.x >= 850 && msg.x <= 850 + 200 && msg.y >= 50 && msg.y <= 50 + 30)
{
system("cls");
cleardevice();
jiemian1();
return;
}
default:
break;
}
}
}
}
void ditucha()
{
cleardevice();
initgraph(1080, 729, EW_SHOWCONSOLE);
IMAGE img;
loadimage(&img, "./xiaoyuantidu.jpg");
putimage(0, 0, &img);
button(30, 530, 150, 30, "0.西大门");
button(200, 530, 150, 30, "6.石油魂");
button(100, 650, 150, 30, "9.校医院");
button(250, 600, 250, 30, "11.教职工区域");
button(720, 380, 150, 30, "8.图书馆");
button(230, 100, 350, 30, "5.生活区");
button(180, 250, 150, 30, "7.体育馆");
button(350, 300, 150, 30, "3.龙井湖");
button(450, 320, 150, 30, "4.情人岛");
button(500, 400, 150, 30, "10.龙井苑");
button(880, 500, 150, 30, "1.健身房");
button(850, 10, 200, 30, "返回上界面");
button(850, 50, 200, 30, "返回主界面");
shubiao4();
}
void biaohao()
{
cleardevice();
printf("\n");
printf(" *********欢迎使用校园导游系统:*********\n");
printf(" ________________________________________________________________\n");
printf(" |----> 支持查询的地点 <----|\n");
printf(" |---->(0)西大门 <----|\n");
printf(" |---->(1)健身房 <----|\n");
printf(" |---->(2)教学区 <----|\n");
printf(" |---->(3)龙井湖 <----|\n");
printf(" |---->(4)情人岛 <----|\n");
printf(" |---->(5)生活区 <----|\n");
printf(" |---->(6)石油魂 <----|\n");
printf(" |---->(7)体育馆 <----|\n");
printf(" |---->(8)图书馆 <----|\n");
printf(" |---->(9)校医院 <----|\n");
printf(" |---->(10)龙井苑 <----|\n");
printf(" |---->(11)教职工区域 <----|\n");
printf(" |______________________________________________________________|\n");
int a=0, b=0;
printf("输入你想查询的两个地点的编号:\n");
scanf_s("%d%d", &a, &b);
printf("\t\t\n");
printf("%d地点到%d地点最短路径长度为: ", a, b);
printf("%d\n", ditu[a][b]);
printf("%d地点到%d地点经过路程地点为: ", a, b);
Path(a, b, push);
printf("%s\n", jq[b].jingdian_name);
printf("\n按任意键返回上界面\n\n");
system("pause");
system("cls");
jiemian2();
}
void diming()
{
cleardevice();
int a=0, b=0;
printf(" *********欢迎使用校园导游系统:*********\n");
printf(" ________________________________________________________________\n");
printf(" |----> 支持查询的地点 <----|\n");
printf(" |---->(0)西大门 <----|\n");
printf(" |---->(1)健身房 <----|\n");
printf(" |---->(2)教学区 <----|\n");
printf(" |---->(3)龙井湖 <----|\n");
printf(" |---->(4)情人岛 <----|\n");
printf(" |---->(5)生活区 <----|\n");
printf(" |---->(6)石油魂 <----|\n");
printf(" |---->(7)体育馆 <----|\n");
printf(" |---->(8)图书馆 <----|\n");
printf(" |---->(9)校医院 <----|\n");
printf(" |---->(10)龙井苑 <----|\n");
printf(" |---->(11)教职工区域 <----|\n");
printf(" |______________________________________________________________|\n");
printf("输入你想查询的两个地点的地名:\n");
char k1[255], k2[255], di[255];
cin >> k1 >> k2;
for (int i = 0; i <= 11; i++) {
strcpy(di, jq[i].jingdian_name);
if (strcmp(di, k1) == 0) {
a = jq[i].bianhao;
}
if (strcmp(di, k2) == 0) {
b = jq[i].bianhao;
}
}
printf("\t\t\n");
cout << " " << k1 << " ";
printf("到");
cout << " " << k2 << " ";
printf("最短路径长度为: ");
printf("%d\n", ditu[a][b]);
cout << " " << k1 << " ";
printf("到");
cout << " " << k2 << " ";
printf("经过路程地点为: ");
Path(a, b, push);
printf("%s\n", jq[b].jingdian_name);
printf("\n按任意键返回上界面\n\n");
system("pause");
system("cls");
jiemian2();
}
void shubiao3()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 350 && msg.y >= 250 && msg.y <= 250 + 30)
{
ditucha();
}
else if (msg.x >= 400 && msg.x <= 400 + 350 && msg.y >= 350 && msg.y <= 350 + 30)
{
biaohao();
}
else if (msg.x >= 400 && msg.x <= 400 + 350 && msg.y >= 450 && msg.y <= 450 + 30)
{
diming();
}
else if (msg.x >= 400 && msg.x <= 400 + 350 && msg.y >= 550 && msg.y <= 550 + 50)
{
jiemian2();
return;
}
else if (msg.x >= 400 && msg.x <= 400 + 350 && msg.y >= 650 && msg.y <= 650 + 50)
{
jiemian1();
return;
}
default:
break;
}
}
}
}
void zuiduanlu()
{
geshihua();
geshi();
floyd();
initgraph(1080, 729, EW_SHOWCONSOLE);
cleardevice();
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
setfillcolor(YELLOW);
settextstyle(50, 0, "楷体");
outtextxy(300, 50, "欢迎使用校园地图系统");
outtextxy(400, 100, "点击你的选择");
button(400, 250, 350, 30, "1.点击地图查询");
button(400, 350, 350, 30, "2.输入地图编号查询");
button(400, 450, 350, 30, "3.输入地图名称查询");
button(400, 550, 350, 30, "4.返回上界面");
button(400, 650, 350, 30, "5.返回主界面");
shubiao3();
}
void shubiao6()
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 450 && msg.x <= 450 + 150 && msg.y >= 400 && msg.y <= 400 + 50)
{
jiemian2();
}
else if (msg.x >= 450 && msg.x <= 450 + 150 && msg.y >= 450 && msg.y <= 450 + 50)
{
jiemian1();
}
default:
break;
}
}
}
}
void zhizuochemyuan()
{
initgraph(1080, 729, EW_SHOWCONSOLE);
cleardevice();
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
setfillcolor(YELLOW);
settextstyle(50, 0, "楷体");
outtextxy(300, 50, "欢迎使用校园地图系统");
setfillcolor(WHITE);
settextstyle(40, 0, "楷体");
outtextxy(300, 150, "制作组员:");
outtextxy(300, 200, "官梦瑶");
outtextxy(300, 240, "曾玉洁");
outtextxy(300, 280, "谭金炫");
button(450, 400, 150, 50, "返回上界面");
button(450, 450, 150, 50, "返回主界面");
shubiao6();
}
void shubiao2()//主界面鼠标
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 400 && msg.x <= 400 + 150 && msg.y >= 150 && msg.y <= 150 + 50)
{
xiaoyuanditu();
}
else if (msg.x >= 400 && msg.x <= 400 + 150 && msg.y >= 250 && msg.y <= 250 + 50)
{
jingdianchaxun();
}
else if (msg.x >= 400 && msg.x <= 400 + 150 && msg.y >= 350 && msg.y <= 350 + 50)
{
zuiduanlu();
}
else if (msg.x >= 400 && msg.x <= 400 + 150 && msg.y >= 450 && msg.y <= 450 + 50)
{
zhizuochemyuan();
}
else if (msg.x >= 400 && msg.x <= 400 + 150 && msg.y >= 550 && msg.y <= 550 + 50)
{
cleardevice();
jiemian1();
return;
}
default:
break;
}
}
}
}
void jiemian2()
{
initgraph(1080, 729, EW_SHOWCONSOLE);
cleardevice();
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
setfillcolor(YELLOW);
settextstyle(50, 0, "楷体");
outtextxy(300, 50, "欢迎使用校园地图系统");
outtextxy(380, 100, "点击你的选择");
button(400, 150, 250, 50, "1.校园地图总浏览");
button(400, 250, 250, 50, "2.校内景点查询");
button(400, 350, 250, 50, "3.最短路径查询");
button(400, 450, 250, 50, "4.参与小组成员");
button(400, 550, 250, 50, "5.返回主界面");
shubiao2();
}
void jiemian1() //主界面
{
initgraph(1040, 840);
cleardevice();
IMAGE img;
loadimage(&img, "./ok.jpg");
putimage(0, 0, &img);
setfillcolor(YELLOW);
settextstyle(50, 0, "楷体");
outtextxy(300, 100, "欢迎使用校园地图系统");
button(450, 250, 150, 50, "进入系统");
button(450, 350, 150, 50, "关闭");
shubiao1();
}
void shubiao1()//主界面鼠标
{
ExMessage msg;
while (1) {
if (peekmessage(&msg, EM_MOUSE))
{
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 450 && msg.x <= 450 + 150 && msg.y >= 250 && msg.y <= 250 + 50)
{
jiemian2();
}
else if (msg.x >= 450 && msg.x <= 450 + 150 && msg.y >= 350 && msg.y <= 350 + 50)
{
return ;
}
default:
break;
}
}
}
}
int main() {
jiemian1();
return 0;
}