أرجو من السادة المبرمجين شرح هذا الكود لى للاهمية
وارجو سرعة الرد
وجزاكم الله خيرا

#include"iostream.h"
#include"string.h"
#define MAX 100
void setup(void);
void assert_flight(char*from,char*to,int dist);
void route(char*to);
int match(char*from,char*to);
int find(char*from,char*anywhere);
void is_flight(char*from,char*to);
void pop(char*from,char*to,int dist);
void push(char*from,char*to,int dist);

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;
struct stack
{
char from[20];
char to[20];
int dist;
};
struct stack bt_stack[MAX];
void main(void)
{
char from[20],to[20];
setup();
cout<<"from?";
cin>>from;
cout<<"to=?";
cin>>to;
is_flight(from,to);
route(to);
}
void setup(void)
{
assert_flight("newyork","chicago",1000);
assert_flight("chicago","denver",1000);
assert_flight("newyork","toronto",800);
assert_flight("newyork","denver",1900);
assert_flight("toronto","calgary",1500);
assert_flight("toronto","losangeles",1800);
assert_flight("toronto","chicago",500);
assert_flight("denver","urbana",1000);
assert_flight("denver","houston",1500);
assert_flight("houston","losangeles",1500);
assert_flight("denver","losangeles",1000);
}
void assert_flight(char*from,char*to,int dist)
{
if(f_pos<MAX)
{
strcpy(flight[f_pos].from,from);
strcpy(flight[f_pos].to,to);
flight[f_pos].distance=dist;
flight[f_pos].skip=0;
f_pos++;
}
else cout<<"flight database full";
}
void route(char*to)
{
int dist,t;
t=0;
dist=0;
while(t<tos)
{
cout<<"to "<<bt_stack[t].from<<"\n";
dist+=bt_stack[t].dist;
t++;
}
cout<<"\n"<<"to ";
cout<<"distance is "<<dist<<"\n";
}
int match(char*from,char*to)
{
register int t;
for(t=f_pos-1;t>-1;t--)
if(!strcmp(flight[t].from,from)&&!strcmp(flight[t].to,to))return flight[t].distance;
return 0;
}
int find(char*from,char*anywhere)
{
find_pos=0;
while(find_pos<f_pos)
{
if(!strcmp(flight[find_pos].from,from)&&!flight[find_pos].skip)
{
strcpy(anywhere,flight[find_pos].to);
flight[find_pos].skip=1;
return flight[find_pos].distance;
}
find_pos++;
}
return 0;
}
void is_flight(char*from,char*to)
{
int d,temp,dist;
char anywhere[20];
cout<<"is flight";
while(dist=find(from,anywhere))
{
if(d=match(from,to))
{
push(from,to,dist);
push(anywhere,to,d);
return;
}
}
if(dist=find(from,anywhere))
{
push(from,to,dist);
is_flight(anywhere,to);
}
else if(tos>0)
{
pop(from,to,dist);
is_flight(from,to);
}
}
void push(char*from,char*to,int dist)
{
if(tos<MAX)
{
strcpy(bt_stack[tos].from,from);
strcpy(bt_stack[tos].to,to);
bt_stack[tos].dist=dist;
tos++;
}
else cout<<"stack full.\n";
}
void pop(char*from,char*to,int dist)
{
if(tos>0)
{
tos--;
strcpy(from,bt_stack[tos].from);
strcpy(to,bt_stack[tos].to);
dist=bt_stack[tos].dist;
}
else cout<<"stack underflow."<<"\n";
}