其实这个是团队项目来着,所以我专门找了我们寝室美术设计师帮我搞背景界面的图片,其实我自己来也行,就是会拉跨很多,不过反而可能会产生喜剧效果。
我的话基本就就近原则,写的项目就是校园导游系统
不过我的为了做可视化界面什么什么玩意,写的是ege版的,不过前面的dijkstra和floyd算法可以参考,后面的大概就是不行了,因为很多图片和文件都是我自己找的
运行结果如图
话不多说,上代码。
#include <iostream>
#include<bits/stdc++.h>
#include<graphics.h>
#define N 114514
using namespace std;
typedef pair<int,int>p;
vector<p>h[N];//邻接表存图
int st[N];//记录走过的节点
int dist[N];//存主门到别的节点的最短路的长度
int dijroute[N];//存主门到各个节点的路径
int mat[100][100];//邻接矩阵存图
int floydroute[100][100];//存各个景点间的最短路径
mouse_msg msg={0};//鼠标指针
char dt[20][20]={"主门","体育馆","主楼","A区","联通广场","文化广场","旧图书馆","B区","体育场","汇文楼","C区"};
void menu();//打印菜单
void Jumpinterface(int c);//界面跳转
void Mainsystem();//主系统函数
void door();//测试函数(不用在意)
void Scenicspotinformationbackground();//景点资料背景
void PathQueryBackground();//路径查询背景
void mjPathquery(int c);//门到景点路径查询
void Selectioninterface();//景点到景点路径查询的选择另外一个景点的界面
void jjPathquery(int c);//景点到景点路径查询
void maindoor();//主门
void Gymnasium();//体育馆
void mainbuilding();//主楼
void Aqu();//A区
void UnicomPlaza();//联通广场
void CulturalSquare();//文化广场
void oldlibrary();//旧图书馆
void Bqu();//B区
void stadium();//体育场
void HuiwenBuilding();//汇文楼
void Cqu();//C区
void Pathsetting();//设定景点之间的路径和长度
void dijkstra();//迪杰斯特拉算法求最短路
void floyd();//Floyd算法求各个点间的最短路
void dijkstra()
{
dijroute[1]=1;
memset(dist,0x3f,sizeof(dist));
priority_queue<p,vector<p>,greater<p>>q;
dist[1]=0;
q.push({0,1});
while(!q.empty())
{
p now=q.top();
q.pop();
int ne=now.second;
if(st[ne])continue;
st[ne]=1;
for(auto it:h[ne])
{
if(dist[it.first]>dist[ne]+it.second){
dist[it.first]=dist[ne]+it.second;
dijroute[it.first]=ne;
q.push({dist[it.first],it.first});
}
}
}
}
void floyd()
{
for(int i=1;i<=11;i++)
{
for(int j=1;j<=11;j++)
{
floydroute[i][j]=j;
}
}
for(int k=1;k<=11;k++)
{
for(int i=1;i<=11;i++)
{
for(int j=1;j<=11;j++)
{
if(mat[i][j]>mat[i][k]+mat[k][j])
{
mat[i][j]=mat[i][k]+mat[k][j];
floydroute[i][j]=floydroute[i][k];
}
}
}
}
}
void menu()
{
resizewindow(1000,530);
PIMAGE mp=newimage();
getimage(mp,"ditu.png");
putimage(0,0,mp);
setfont(50,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(10,10,200,200,"选择要查询的地点");
xyprintf(900,10,"退出");
}
void Scenicspotinformationbackground()
{
resizewindow(1200,675);
setbkcolor(WHITE);
PIMAGE bk=newimage();
getimage(bk,"景点资料背景.jpg");
putimage(0,0,bk);
delimage(bk);
}
void PathQueryBackground()
{
resizewindow(1200,675);
setbkcolor(WHITE);
PIMAGE bk=newimage();
getimage(bk,"景点路径背景.jpg");
putimage(0,0,bk);
delimage(bk);
}
void mjPathquery(int c)
{
PathQueryBackground();
if(c==1)
{
setfont(50,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
xyprintf(375,320,"这就是主门");
}
else
{
int x=c;
int num=0;
int lu[20];
num++;
lu[num]=x;
while(dijroute[x]!=x)
{
x=dijroute[x];
num++;
lu[num]=x;
}
setfont(50,0,"幼圆");
setcolor(LIGHTGREEN);
setbkmode(TRANSPARENT);
xyprintf(100,30,"主门到%s的最短路径要经过的景点:",dt[c-1]);
setfont(50,0,"黑体");
setcolor(WHITE);
for(int i=num;i>=1;i--)
{
xyprintf(400,(i)*70+60,"%s",dt[lu[i]-1]);
}
setfont(50,0,"幼圆");
setcolor(LIGHTGREEN);
xyprintf(80,600,"主门到%s的最短路径长度为%dm",dt[c-1],dist[c]);
}
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=962&&msg.x<=1139)&&(msg.y>=530&&msg.y<=632))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"返回键.png");
putimage(960,526,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
break;
}
}
else
{
if(!panan)
{
panan=true;
mjPathquery(c);
}
}
}
Jumpinterface(c);
}
void Selectioninterface()
{
resizewindow(1200,675);
PIMAGE bk=newimage();
getimage(bk,"景景路径查询的选择另外一个景点界面.jpg");
putimage(0,0,bk);
delimage(bk);
setfont(50,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
xyprintf(70,550,"选择要查询的路径的终点");
}
void jjPathprinting(int c,int cc)
{
PathQueryBackground();
if(cc==12)
Jumpinterface(c);
else if(c==cc)
{
setfont(50,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
xyprintf(375,320,"这就是%s",dt[c-1]);
}
else
{
int num=0;
int lu[20];
num++;
lu[num]=c;
int s=floydroute[c][cc];
while(s!=cc)
{
num++;
lu[num]=s;
s=floydroute[s][cc];
}
num++;
lu[num]=cc;
setfont(50,0,"幼圆");
setcolor(LIGHTGREEN);
setbkmode(TRANSPARENT);
xyprintf(100,30,"%s到%s的最短路径要经过的景点:",dt[c-1],dt[cc-1]);
setfont(50,0,"黑体");
setcolor(WHITE);
for(int i=1;i<=num/2;i++)
{
int k=lu[i];
lu[i]=lu[num-i+1];
lu[num-i+1]=k;
}
for(int i=num;i>=1;i--)
{
xyprintf(400,(i)*70+60,"%s",dt[lu[i]-1]);
}
setfont(50,0,"幼圆");
setcolor(LIGHTGREEN);
xyprintf(80,600,"%s到%s的最短路径长度为%dm",dt[c-1],dt[cc-1],mat[c][cc]);
}
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=962&&msg.x<=1139)&&(msg.y>=530&&msg.y<=632))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"返回键.png");
putimage(960,526,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
break;
}
}
else
{
if(!panan)
{
panan=true;
jjPathprinting(c,cc);
}
}
}
jjPathquery(c);
}
void jjPathquery(int c)
{
Selectioninterface();
mouse_msg msg={0};
bool panan=true;
int cc;
while(1)
{
msg=getmouse();
if((msg.x>=35&&msg.x<=251)&&(msg.y>=43&&msg.y<=144))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主门按键.png");
putimage(35,43,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=1;
break;
}
}
else if((msg.x>=31&&msg.x<=255)&&(msg.y>=210&&msg.y<=309))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"体育馆按键.png");
putimage(31,210,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=2;
break;
}
}
else if((msg.x>=31&&msg.x<=251)&&(msg.y>=389&&msg.y<=489))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主楼按键.png");
putimage(31,389,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=3;
break;
}
}
else if((msg.x>=662&&msg.x<=881)&&(msg.y>=390&&msg.y<=489))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"A区按键.png");
putimage(655,389,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=4;
break;
}
}
else if((msg.x>=332&&msg.x<=553)&&(msg.y>=390&&msg.y<=489))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"联通广场按键.png");
putimage(331,389,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=5;
break;
}
}
else if((msg.x>=663&&msg.x<=878)&&(msg.y>=215&&msg.y<=314))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"文化广场按键.png");
putimage(655,207,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=6;
break;
}
}
else if((msg.x>=330&&msg.x<=555)&&(msg.y>=212&&msg.y<=312))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"旧图书馆按键.png");
putimage(330,212,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=7;
break;
}
}
else if((msg.x>=330&&msg.x<=555)&&(msg.y>=212&&msg.y<=312))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"旧图书馆按键.png");
putimage(330,212,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=7;
break;
}
}
else if((msg.x>=957&&msg.x<=1177)&&(msg.y>=44&&msg.y<=146))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"B区按键.png");
putimage(954,40,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=8;
break;
}
}
else if((msg.x>=330&&msg.x<=555)&&(msg.y>=40&&msg.y<=140))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"体育场按键.png");
putimage(330,40,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=9;
break;
}
}
else if((msg.x>=655&&msg.x<=880)&&(msg.y>=40&&msg.y<=140))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"汇文楼按键.png");
putimage(655,40,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=10;
break;
}
}
else if((msg.x>=953&&msg.x<=1177)&&(msg.y>=207&&msg.y<=310))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"C区按键.png");
putimage(953,207,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=11;
break;
}
}
else if((msg.x>=953&&msg.x<=1177)&&(msg.y>=490&&msg.y<=592))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"返回按键2.png");
putimage(953,490,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
cc=12;
break;
}
}
else
{
if(!panan)
{
panan=true;
Selectioninterface();
}
}
}
jjPathprinting(c,cc);
}
void door()//测试用函数
{
cleardevice();
PIMAGE x1=newimage();
getimage(x1,"cs.png");
putimage(0,0,x1);
getch();
Mainsystem();
}
void maindoor()
{
Scenicspotinformationbackground();
PIMAGE tu=newimage();
getimage(tu,"主门.jpg");
putimage(616,56,tu);
delimage(tu);
FILE*f=NULL;
f=fopen("maindoor.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
maindoor();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(1);
break;
}
case 2:
{
jjPathquery(1);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void Gymnasium()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("Gymnasium.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
Gymnasium();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(2);
break;
}
case 2:
{
jjPathquery(2);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void mainbuilding()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("mainbuilding.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
mainbuilding();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(3);
break;
}
case 2:
{
jjPathquery(3);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void Aqu()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("Aqu.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
Aqu();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(4);
break;
}
case 2:
{
jjPathquery(4);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void UnicomPlaza()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("UnicomPlaza.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
UnicomPlaza();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(5);
break;
}
case 2:
{
jjPathquery(5);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void CulturalSquare()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("CulturalSquare.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
CulturalSquare();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(6);
break;
}
case 2:
{
jjPathquery(6);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void oldlibrary()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("oldlibrary.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
oldlibrary();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(7);
break;
}
case 2:
{
jjPathquery(7);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void Bqu()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("Bqu.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
Bqu();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(8);
break;
}
case 2:
{
jjPathquery(8);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void stadium()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("stadium.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
stadium();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(9);
break;
}
case 2:
{
jjPathquery(9);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void HuiwenBuilding()
{
Scenicspotinformationbackground();
PIMAGE tu=newimage();
getimage(tu,"汇文楼.jpg");
putimage(616,56,tu);
delimage(tu);
FILE*f=NULL;
f=fopen("HuiwenBuilding.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
HuiwenBuilding();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(10);
break;
}
case 2:
{
jjPathquery(10);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void Cqu()
{
Scenicspotinformationbackground();
FILE*f=NULL;
f=fopen("Cqu.txt","r");
char tx[100]={0};
fscanf(f,"%s",tx);
setfont(30,0,"黑体");
setcolor(WHITE);
setbkmode(TRANSPARENT);
rectprintf(142,93,410,589,"%s",tx);
setfont(50,0,"黑体");
xyprintf(1100,0,"返回");
int c;
mouse_msg msg={0};
bool panan=true;
while(1)
{
msg=getmouse();
if((msg.x>=816&&msg.x<=1130)&&(msg.y>=435&&msg.y<=515))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"主景路径按钮.png");
putimage(810,430,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>=816&&msg.x<=1130)&&(msg.y>=550&&msg.y<=631))
{
if(panan)
{
PIMAGE an=newimage();
getimage(an,"景景路径按钮.png");
putimage(810,545,an);
delimage(an);
panan=false;
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>=1100&&msg.x<=1200)&&(msg.y>=0&&msg.y<=50))
{
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else
{
if(!panan)
{
Cqu();
panan=true;
}
}
}
switch(c)
{
case 1:
{
mjPathquery(11);
break;
}
case 2:
{
jjPathquery(11);
break;
}
case 3:
{
Mainsystem();
break;
}
}
}
void Jumpinterface(int c)
{
switch(c)
{
case 1:
{
maindoor();
break;
}
case 2:
{
Gymnasium();
break;
}
case 3:
{
mainbuilding();
break;
}
case 4:
{
Aqu();
break;
}
case 5:
{
UnicomPlaza();
break;
}
case 6:
{
CulturalSquare();
break;
}
case 7:
{
oldlibrary();
break;
}
case 8:
{
Bqu();
break;
}
case 9:
{
stadium();
break;
}
case 10:
{
HuiwenBuilding();
break;
}
case 11:
{
Cqu();
break;
}
case 12:
{
break;
}
}
}
void Mainsystem()
{
menu();
bool panan=true;
int c;
while(1)
{
msg=getmouse();
if((msg.x>0&&msg.x<165)&&(msg.y>200&&msg.y<300))//主门
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"zhenmen.png");
putimage(0,180,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=1;
break;
}
}
else if((msg.x>200&&msg.x<300)&&(msg.y>20&&msg.y<100))//体育馆
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"tiyuguan.png");
putimage(206,31,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=2;
break;
}
}
else if((msg.x>300&&msg.x<430)&&(msg.y>180&&msg.y<250))//主楼
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"zhulou.png");
putimage(300,183,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=3;
break;
}
}
else if((msg.x>190&&msg.x<270)&&(msg.y>350&&msg.y<410))//A区
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"aqu.png");
putimage(197,353,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=4;
break;
}
}
else if((msg.x>465&&msg.x<595)&&(msg.y>180&&msg.y<225))//联通广场
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"liantonguanchan.png");
putimage(463,182,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=5;
break;
}
}
else if((msg.x>337&&msg.x<337+107)&&(msg.y>443&&msg.y<443+79))//文化广场
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"wenhuaguanchan.png");
putimage(335,430,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=6;
break;
}
}
else if((msg.x>546&&msg.x<546+67)&&(msg.y>38&&msg.y<38+118))//旧图书馆
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"jiutushuguan.png");
putimage(544,37,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=7;
break;
}
}
else if((msg.x>552&&msg.x<552+172)&&(msg.y>250&&msg.y<250+226))//B区
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"bqu.png");
putimage(559,240,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=8;
break;
}
}
else if((msg.x>661&&msg.x<661+186)&&(msg.y>16&&msg.y<116))//体育场
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"tiyuchan.png");
putimage(661,16,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=9;
break;
}
}
else if((msg.x>820&&msg.x<820+130)&&(msg.y>185&&msg.y<185+65))//汇文楼
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"huiwenlou.png");
putimage(818,182,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=10;
break;
}
}
else if((msg.x>804&&msg.x<804+174)&&(msg.y>342&&msg.y<342+129))//C区
{
if(panan){
panan=false;
PIMAGE an=newimage();
getimage(an,"cqu.png");
putimage(804,342,an);
delimage(an);
}
if(msg.is_left()==1&&msg.is_up()==1)
{
c=11;
break;
}
}
else if((msg.x>900&&msg.x<1000)&&(msg.y>10&&msg.y<60)&&msg.is_left()==1&&msg.is_up()==1)//退出
{
c=12;
break;
}
else
{
if(!panan)
{
panan=true;
menu();
}
}
}
Jumpinterface(c);
cleardevice();
resizewindow(1000, 800);
setfont(50,0,"华文琥珀");
setcolor(WHITE);
setbkmode(TRANSPARENT);
xyprintf(450,375,"感谢");
getch();
return;
}
int main()
{
Pathsetting();
dijkstra();
floyd();
initgraph(1000,800,INIT_RENDERMANUAL);
PIMAGE pimg=newimage();
getimage(pimg,"START.jpg");
putimage(0,0,pimg);
setfont(100,0,"幼圆");
setcolor(DARKGRAY);
setbkmode(TRANSPARENT);
char s[100]="欢迎使用校园导游系统";
rectprintf(0,100,600,500,"%s",s);
setfont(30,0,"幼圆");
setcolor(WHITE);
outtextxy(0,700,"点击继续......");
while(1)
{
msg=getmouse();
if((msg.x>0&&msg.x<1000)&&(msg.y>0&&msg.y<800)&&msg.is_left()==1&&msg.is_up()==1)
{
break;
}
}
cleardevice();
delimage(pimg);
Mainsystem();
return 0;
}
void Pathsetting()
{
memset(mat,0x3f,sizeof(mat));
for(int i=1;i<100;i++)mat[i][i]=0;
h[1].push_back({2,200}),h[2].push_back({1,200}),mat[1][2]=200,mat[2][1]=200;
h[1].push_back({3,100}),h[3].push_back({1,100}),mat[1][3]=100,mat[3][1]=100;
h[1].push_back({4,400}),h[4].push_back({1,400}),mat[1][4]=400,mat[4][1]=400;
h[2].push_back({3,100}),h[3].push_back({2,100}),mat[2][3]=100,mat[3][2]=100;
h[3].push_back({5,100}),h[5].push_back({3,100}),mat[3][5]=100,mat[5][3]=100;
h[3].push_back({6,160}),h[6].push_back({3,160}),mat[3][6]=160,mat[6][3]=160;
h[4].push_back({6,300}),h[6].push_back({4,300}),mat[4][6]=300,mat[6][4]=300;
h[5].push_back({7,100}),h[7].push_back({5,100}),mat[5][7]=100,mat[7][5]=100;
h[6].push_back({8,180}),h[8].push_back({6,180}),mat[6][8]=180,mat[8][6]=180;
h[7].push_back({9,50}),h[9].push_back({7,50}),mat[7][9]=50,mat[9][7]=50;
h[8].push_back({9,150}),h[9].push_back({8,150}),mat[8][9]=150,mat[9][8]=150;
h[8].push_back({10,150}),h[10].push_back({8,150}),mat[8][10]=150,mat[10][8]=150;
h[8].push_back({11,100}),h[11].push_back({8,100}),mat[8][11]=100,mat[11][8]=100;
h[10].push_back({11,250}),h[11].push_back({10,250}),mat[10][11]=250,mat[11][10]=250;
}