📄 rui2.cpp
字号:
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<stdio.h>
#include "graphics.h"
#include "conio.h"
#include "dos.h"
void *buffer;
FILE *al;
int Key(void)
{
union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}
void hz(int x,int y,int a,int COL,int b,char *s)
{
int ROW;
char buffer[32];
register m,n,i,j,k;
unsigned char qh,wh;
unsigned long offset;
ROW=COL;
while(*s)
{
qh=*(s)-0xa0;
wh=*(s+1)-0xa0;
offset=(94*(qh-1)+(wh-1))*32L;
fseek(al,offset,SEEK_SET);
fread(buffer,32,1,al);
for (i=0;i<16;i++)
for(n=0;n<ROW;n++)
for(j=0;j<2;j++)
for(k=0;k<8;k++)
for(m=0;m<COL;m++)
if (((buffer[i*2+j]>>(7-k))&0x1)!=NULL)
putpixel(x+8*j*COL+k*COL+m,y+i*ROW+n,b);
s+=2;
x+=a;
}
}
#define MAX_VERTEX_NUM 10
#define INFINITY 10000
#define MAX MAX_VERTEX_NUM
#define true 1
#define false 0
#define large 999
struct AlGraph{
int vertices[MAX];
int vexnum;
int arcs[MAX][MAX];
};
char name[10][150]={
"scenery one of Northwestern Polytechnical University",
"scenery two of Northwestern Polytechnical University",
"scenery three of Northwestern Polytechnical University",
"scenery four of Northwestern Polytechnical University",
"scenery five of Northwestern Polytechnical University",
"scenery six of Northwestern Polytechnical University",
"scenery seven of Northwestern Polytechnical University",
"scenery eight of Northwestern Polytechnical University",
"scenery nine of Northwestern Polytechnical University",
"scenery ten of Northwestern Polytechnical University",
};
char intro[10][100]={
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
"Welcome to visit the website of Northwestern Polytechnical University",
};
void acquiry_places (struct AlGraph G)
{setbkcolor(LIGHTBLUE);
rectangle(20,20,620,460);
rectangle(10,10,630,470);
int i;
setcolor(LIGHTBLUE);
printf("\n\n\n");
for ( i=0;i<G.vexnum;i++)
{
printf(" ");
printf("%d,\t %s\n",i+1,name[i]);
if ( i%10==9 )
{ printf("please input enter continue \n");
getchar();
}
}
getchar();
}
void acquiry_info ()
{
int i,j;
printf("please input the number of the scenic spots you want to inquire about : \t");
scanf( "%d",&j);
printf(" %d, %s \n",j,name[j-1]);
printf(" %s\n",intro[j-1]);
getchar();
printf("please input enter and continue\n");
getchar();
}
void help()
{
int Driver=DETECT,Mode;
initgraph(&Driver,&Mode,"c:\\tc30\\bgi");
setbkcolor(LIGHTBLUE);
if ((al=fopen("hzk16","rb"))==NULL)
{ printf("Can't open haz16,Please add it");
getch(); closegraph(); exit(0);
}
rectangle(20,20,620,460);
rectangle(10,10,630,470);
hz(80,50,40,2,10,"帮助说明文件");
hz(30,100,25,1,10,"运行环境三点零版本下运行成功");
hz(30,150,25,1,10,"操作说明相应数字键选择");
hz(30,200,25,1,10,"算法采用迪杰斯特拉算法求最短路径");
hz(30,250,25,1,10,"作者:杨玉蕊");
hz(30,300,25,1,10,"二零零五年六月十日完成");
getch();
}
void shortpath(struct AlGraph G)
{
int cost[MAX][MAX];
int dist[MAX];
int path[MAX];
int s[MAX];
int i,j,n,v0,min,u,k;
int m1,m2;
rectangle(20,20,620,460);
rectangle(10,10,630,470);
printf("\n please input the number of starting point :");
scanf("%d",&v0);
if( v0<=0 || v0>G.vexnum )
{ printf("\n input error \n");
exit(-1);
}
printf("please input the number of arrive : ");
scanf("%d",&k);
if( k<=0 || k>G.vexnum )
{ printf("\n input error \n");
exit(-1);
}
printf(" please input enter continue\n");
getchar();
m1=v0;
m2=k;
v0--;
k--;
for(i=0;i<G.vexnum;i++)
{
for(j=0;j<G.vexnum;j++)
cost[i][j]=G.arcs[i][j];
}
printf(" initialize end \n");
getchar();
for(i=0;i<G.vexnum;i++)
{ dist[i]=cost[v0][i];
if(dist[i]<large&&dist[i]>0) path[i]=v0;
s[i]=0;
}
printf(" end \n");
getchar();
clrscr();
s[v0]=1;
for(i=0;i<G.vexnum;i++)
{ min=large;
u=v0;
for(j=0;j<G.vexnum;j++)
if(s[j]==0&&dist[j]<min)
{min=dist[j];u=j;}
s[u]=1;
for(j=0;j<G.vexnum;j++)
if(s[j]==0&&dist[u]+cost[u][j]<dist[j])
{ dist[j]=dist[u]+cost[u][j];
path[j]=u;
}
}
printf("out %s the distance to the scenery \n" ,name[m1-1]);
for(i=0;i<G.vexnum;i++)
if(i!=m1-1)
printf(" %d M \t %s \n",dist[i],name[i]);
getchar();
printf("\n %s to %s the way :\n",name[m1-1],name[m2-1]);
getchar();
i=m1;
printf("%s\t",name[u]);
if(s[i]==1)
{ u=i;
while(u!=v0)
{ getchar();
printf("middle way--- %s ",name[u]);
u=path[u];
}
printf("\n the lenth of section %d M ",dist[i]);
printf(" \n output end \n");
getchar();
}
}
void picture()
{int k=1,i,j;
int parcs[22]={300,100,400,140,430,190,430,250,380,320,280,300,240,220,260,180,270,150,285,120,300,100};
int Driver=DETECT,Mode;
initgraph(&Driver,&Mode,"c:\\tc30\\bgi");
setbkcolor(LIGHTBLUE);
if ((al=fopen("hzk16","rb"))==NULL)
{ printf("Can't open haz16,Please add it");
getch(); closegraph(); exit(0);
}
rectangle(20,20,620,460);
rectangle(10,10,630,470);
hz(80,50,40,2,10,"西北工大校园景点平面图");
hz(30,400,25,1,10,"作者:杨玉蕊");
hz(250,400,25,1,10,"完成时间:二零零五年六月十日");
moveto(300,100);
for(k=0;k<=21;k++)
{
i=parcs[k];
k++;
j=parcs[k];
lineto(i,j);
}
line(300,100,430,190);
line(430,190,280,300);
line(285,120,430,190);
line(400,140,240,220);
line(430,250,240,220);
line(300,100,380,320);
getch();
}
main()
{ int i,j;
struct AlGraph G;
G.vexnum=10;
clrscr();
for(i=0;i<G.vexnum;i++)
for(j=0;j<G.vexnum;j++)
G.arcs[i][j]=INFINITY;
for(i=0;i<G.vexnum;i++)
G.arcs[i][i]=0;
G.arcs[0][1]=100; G.arcs[0][2]=200; G.arcs[0][8]=100;
G.arcs[0][4]=400;
G.arcs[1][0]=100; G.arcs[1][2]=100;
G.arcs[1][6]=400;
G.arcs[2][0]=200;
G.arcs[2][3]=100; G.arcs[2][5]=300; G.arcs[2][8]=200;
G.arcs[3][2]=100; G.arcs[3][4]=100;
G.arcs[3][7]=300;
G.arcs[4][0]=400; G.arcs[4][3]=100; G.arcs[4][5]=100;
G.arcs[5][2]=300; G.arcs[5][4]=100; G.arcs[5][6]=100;
G.arcs[6][5]=100; G.arcs[6][7]=100; G.arcs[6][1]=400;
G.arcs[7][3]=300; G.arcs[7][6]=100; G.arcs[7][8]=100;
G.arcs[8][2]=200; G.arcs[8][5]=200; G.arcs[8][7]=100; G.arcs[8][0]=100;
int GD=DETECT,GM;
initgraph(&GD,&GM,"c:\\tc30\\bgi");
setbkcolor(LIGHTBLUE);
if ((al=fopen("hzk16","rb"))==NULL)
{ printf("Can't open haz16,Please add it");
getch(); closegraph(); exit(0);
}
rectangle(20,20,620,460);
rectangle(10,10,630,470);
setfillstyle(XHATCH_FILL,BROWN);
bar3d(80,165,160,265,10,1);
setcolor(YELLOW);
hz(87,200,18,1,WHITE,"西北工大");
hz(220,100,40,2,LIGHTGREEN,"校园导航系统");
hz(220,160,20,1,YELLOW,"设计人员:杨玉蕊");
hz(220,200,20,1,YELLOW,"设计时间:二零零五年六月七日至十日");
settextstyle(DEFAULT_FONT,HORIZ_DIR,0); //设置文本输出格式
setcolor(YELLOW);
settextstyle(TRIPLEX_FONT,0,1);
outtextxy(216,230," QQ:125254122");
hz(220,265,25,1,YELLOW,"请按回车键进入主界面");
getch();
loop: clrscr();
initgraph(&GD,&GM,"c:\\tc30\\bgi");
setbkcolor(LIGHTBLUE);
rectangle(1,1,639,479);
hz(80,20,40,2,10,"西北工业大学校园导航系统");
hz(40,80,25,1,11,"【一】输出所有的景点");
hz(40,120,25,1,11,"【二】输出你所选择的景点相关信息");
hz(40,160,25,1,11,"【三】获取所选景点间的最短路径");
hz(40,200,25,1,11,"【四】画出校园导游图的仿真界面");
hz(40,240,25,1,11,"【五】查看帮助文件");
hz(40,280,25,1,11,"【六】退出");
hz(40,320,25,1,11,"请选择相应的操作相应数字键然后按回车键选择");
rectangle(540,450,637,477);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
hz(570,455,15,1,YELLOW,"杨玉蕊");
rectangle(1,450,637,477);
hz(180,455,20,1,YELLOW,"操作不清楚谨请查阅操作手则");
scanf("%d",&i );
clrscr();
switch(i)
{ case 1 : acquiry_places(G);break;
case 2 : acquiry_info();break;
case 3 : shortpath (G) ;break;
case 4 : picture() ;break;
case 5 : help() ;break;
case 6 : exit(0);
default: printf(" erroneous input :\n");
}
goto loop;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -