📄 最优解.txt
字号:
#include <stdio.h>
#define MAX 100
struct FL{
char from[20];
char to[20];
int distance;
char skip;/*防止相同的节点被重复试探*/
};
struct FL flight[MAX];
int f_pos=0;/*航班知识库中的航线数*/
int find_pos=0;/*搜索航班知识库时的索引*/
int tos=0;/*栈顶*/
int stos=0;
struct stack{/*回溯堆栈,保存路径*/
char from[20];
char to[20];
int dist;
};
struct stack bt_stack[MAX];
struct stack solution[MAX];
main()
{
char from[20],to[20];
int t,d;
setup();
printf("from?");
gets(from);
printf("to?");
gets(to);
do{
isflight(from,to);
d=route(to);
tos=0;
}while(d!=0);
t=0;
printf("Optimal solution is:\n");
while(t<stos){
printf("%s -> ",solution[t].from);
d+=solution[t].dist;
t++;
}
printf("%s\n",to);
printf("distance is %d\n",d);
}
setup()
{
assert_flight("New York","Chicago",1000);
assert_flight("Chicago","Denver",1000);
assert_flight("New York","Toronto",800);
assert_flight("New York","Denver",1900);
assert_flight("Toronto","Calgary",1500);
assert_flight("Toronto","
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -