}
else // Иначе уезжаем дальше
for (i=0; i<num_city; ++i)
if (!visited[i] && !path_time[v*num_city+i].null())
{
// Считаем время ожидания след. поезда
if (v==num_from)
{
time = depar_time[v*num_city+i]+path_time[v*num_city+i];
}
else
{
h = depar_time[v*num_city+i].hour()-time0.hour()%24;
while (h<0) h+=24;
m = depar_time[v*num_city+i].min()-time0.min();
wait.set(h, m);
time = time0+wait+path_time[v*num_city+i];
}
dfs(i, time);
}
// Снимаем отметку
visited[v] = 0;
--depth;
}
#include "app.h"
/////// METHODS COBJECT ///////
void CObject::set(unsigned left, unsigned top, unsigned widthh, unsigned heightt)
{
x = left;
y = top;
width = widthh;
height = heightt;
}
char CObject::focused()
{
return focus;
}
void CObject::set_focus(char focuss)
{
focus = focuss;
}
/////// METHODS CLABEL ///////
void CLabel::draw()
{
setcolor(BLACK);
outtextxy(x, y, caption.get_data());
}
/////// METHODS CEDIT ///////
CEdit::CEdit():CObject()
{
}
void CEdit::draw()
{
setfillstyle(SOLID_FILL, WHITE);
int poly[8];
poly[0] = x;
poly[1] = y;
poly[2] = x+width;
poly[3] = y;
poly[4] = x+width;
poly[5] = y+height;
poly[6] = x;
poly[7] = y+height;
fillpoly(4, poly);
setcolor(BLACK);
moveto(x, y+height);
lineto(x, y);
lineto(x+width, y);
setcolor(WHITE);
lineto(x+width, y+height);
lineto(x, y+height);
setcolor(BLACK);
if (focus) outtextxy(x+2, y+4, (text+"_").get_data());
else outtextxy(x+2, y+4, text.get_data());
}
void CEdit::press_key(unsigned char key)
{
if (key==8 && text.length()>0) text.del_sym(text.length());
if (text.length()<15 && (key>=32 && key<=126 || key>=128 && key<=175 || key>=224 && key<=240))
{
char mas[2];
mas[0] = key;
mas[1] = 0;
text = text+mas;
}
}
CString CEdit::get_text()
{
return text;
}
/////// METHODS CBUTTON ///////
CButton::CButton():CObject()
{
}
void CButton::draw()
{
int poly[8];
setfillstyle(SOLID_FILL, 7);
poly[0] = x;
poly[1] = y;
poly[2] = x+width;
poly[3] = y;
poly[4] = x+width;
poly[5] = y+height;
poly[6] = x;
poly[7] = y+height;
fillpoly(4, poly);
setcolor(WHITE);
moveto(x, y+height);
lineto(x, y);
lineto(x+width, y);
setcolor(BLACK);
lineto(x+width, y+height);
lineto(x, y+height);
outtextxy(x+21, y+9, caption.get_data());
if (focus)
{
setlinestyle(DOTTED_LINE, 1, 1);
rectangle(x+2, y+2,x+width-2, y+height-2);
setlinestyle(SOLID_LINE, 1, 1);
}
}
void CButton::down_up()
{
int poly[8];
setcolor(7);
setfillstyle(SOLID_FILL, 7);
poly[0] = x+4;
poly[1] = y+4;
poly[2] = x+width-4;
poly[3] = y+4;
poly[4] = x+width-4;
poly[5] = y+height-4;
poly[6] = x+4;
poly[7] = y+height-4;
fillpoly(4, poly);
setcolor(BLACK);
outtextxy(x+21+2, y+9+2, caption.get_data());
setcolor(BLACK);
moveto(x, y+height);
lineto(x, y);
lineto(x+width, y);
setcolor(WHITE);
lineto(x+width, y+height);
lineto(x, y+height);
delay(100);
draw();
delay(300);
}
/////// METHODS CFINDBUTTON ///////
CFindButton::CFindButton():CButton()
{
caption = "Поиск";
}
void CFindButton::press_key(CApplication &Application, unsigned char key)
{
if (key==13)
{
int i, j;
down_up();
// Загрузка базы и поиск пути
CBase base("Russia.dat");
CString A = Application.mainform.city1.get_text();
CString B = Application.mainform.city2.get_text();
CString result = base.search_path(A, B);
// Рисование городов
setcolor(WHITE);
setbkcolor(BLACK);
cleardevice();
settextstyle(GOTHIC_FONT,HORIZ_DIR, 4);
outtextxy(300, 0, "Russian Train Network");
settextstyle(DEFAULT_FONT,HORIZ_DIR, 1);
int *coor = base.get_city_coor();
CString *name = base.get_city_name();
for (i=0; i<base.get_num_city(); ++i)
{
if (name[i]==A || name[i]==B) setcolor(RED); else setcolor(WHITE);
outtextxy(coor[2*i]+7, coor[2*i+1]-10, name[i].get_data());
circle(coor[2*i], coor[2*i+1], 2);
}
// Рисование путей
setcolor(WHITE);
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.