输⼊两个点的坐标求两点之间的距离c语⾔,C语⾔求两点之间
的最短路径
#include
#include
# define n 6
# define NULL 0
#define UP 72
#define DOWN 80
#define ESC 27
#define Enter 13
int i1=0,j1=3,m1=0,n1=0;
int start=0;
char str2[][100]={"THE INTRODUTION OF THE ROUTINE !",
"AUGMENT THE RELATIVE DATA !",
"SEARCH FOR THE INFORMATION !",
"QUIT THE ROUTINE !"};
char str3[][100]={"THE ROUTINE WAS PROGRAMED IN ",
" 2006--07--10",
"PROGRAMER : ",
"CAO JUN BIN "};
int dd[n+1][n+1], pp[n+1][n+1],a[n];
typedef struct
{int number;
int edge[n+1][n+1];
}graph;
graph g;
int maxdist=2000,mindist;
struct viewpoint
{int x;
int y;
int number;
char inf[10];
}bd[n];
struct point
int x_1;
int y_1;
}point[n];
typedef struct point f;
struct path
{int V1;
int V2;
int length;
}p[n*n/2];
void mainmenu ();
void con();
void choosepoint() ;
void interface();
void interface1();
void again();
void drawbuilding();
void drawedge();
void floyd(graph g,int m, int dd[n+1][n+1],int pp[n+1][n+1]); void display(int i,int j,int pp[n+1][n+1],int dd[n+1][n+1]); void drawpath();
void buildingmap( );
void pathmap( );
main()
{ int gdriver=9,gmode=2;
initgraph(&gdriver,&gmode,"c:\\TURBOC2");
mainmenu();
}
void mainmenu ()
char c; char str[10];
setbkcolor(BLACK);
setcolor(LIGHTGRAY);
rectangle(20,20,600,475);
settextstyle(4,0,4);
setcolor(LIGHTRED);
outtextxy(160,70,"THE MAIN MENU ");
settextstyle(3,0,1);
setcolor(CYAN);
outtextxy(160,160,str2[0]);
outtextxy(160,200,str2[1]);
outtextxy(160,240,str2[2]);
outtextxy(160,280,str2[3]);
while(flag){ c=getch();
switch(c){case DOWN:i1++;j1++;
m1=i1%4;n1=j1%4;
con();break;
case UP :if(i1==-1)i1=3;if(j1==-1)j1=3;
m1=i1%4;n1=j1%4;a=m1;m1=n1;n1=a;
con();
i1--;j1--;break;
case ESC :flag=0;break;
case Enter:cleardevice();
if(m1==0){interface1();getch();cleardevice();
mainmenu();
}
if(m1==1){ setbkcolor(BLACK);
setcolor(YELLOW);
rectangle(20,20,600,475);
rectangle(30,30,590,465) ;
setcolor(LIGHTRED);
settextstyle(3,0,1);
setcolor(LIGHTRED);
outtextxy(160,160,"PLESE CHOOSE THE SEVICE !");
outtextxy(120,200," AUGMENT THE INFORMATION OF THE BUILDING (B)!"); outtextxy(120,240," AUGMENT THE INFORMATION OF THE BUILDING (P) !"); switch(getch()){case'B':{cleardevice();buildingmap();cleardevice();};break;
case 'P':{cleardevice();pathmap();cleardevice();};break;
default: cleardevice();mainmenu();}
}
if(m1==2){undefined
interface();
getch();}
if(m1==3){exit(0);
}
}
}
}
void con()
{setcolor(YELLOW);
outtextxy(160,160+m1*40,str2[m1]);
setcolor(CYAN);
outtextxy(160,160+n1*40,str2[n1]);
}
void interface()
{ int i,j;
char str[10];
setbkcolor(BLACK);
setcolor(LIGHTGRAY);
rectangle(20,20,600,100);
rectangle (20,20,600,470);
rectangle (20,100,450,470) ;
rectangle(20,350,450,470);
rectangle(20,100,300,350);
settextstyle(3,0,3);
outtextxy(200,30,"WELCOME TO");
outtextxy(120,60,"NORTHEAST DIANLI UNIVERSITY!") ; outtextxy(460,200,"FROM : ___");
outtextxy(485,250,"TO : ___");
settextstyle(2,0,5);
rectangle(475,315,535,335);
rectangle(475,365,535,385);
outtextxy(455,150,"(PLEASE INPUT!)");
outtextxy(175,360,"THE RESULT !");
outtextxy(500,320,"F");
outtextxy(500,370,"Q");
outtextxy(480,400,"Input");
outtextxy(460,420, "the number 1-->6");
setcolor(RED);
drawbuilding();
drawedge();
i=0;
while(i'6') i=getch();
textstylesprintf(str,"%c",i);
outtextxy(560,205,str);
while(j'6') j=getch();
sprintf(str,"%c",j);
outtextxy(560,255,str);
i=i-48;j=j-48;
floyd(g,n,dd[n+1][n+1],pp[n+1][n+1]);
display (i,j,pp[n+1][n+1], dd[n+1][n+1]); drawpath( );
}
void interface1()
{undefined
setbkcolor(BLACK);
setcolor(YELLOW);
rectangle(20,20,600,475);
rectangle(30,30,590,465) ;
settextstyle(4,0,4);
setcolor(LIGHTRED);
settextstyle(3,0,1);
setcolor(LIGHTRED);
outtextxy(160,160,str3[0]);
outtextxy(160,200,str3[1]);
outtextxy(210,240,str3[2]);
outtextxy(210,280,str3[3]);
}
void again()
{int i;
if(start==0) {for (i=0;i<300;i++) delay(1000);} }
void drawbuilding()

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。