⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit2.pas

📁 旅游查询系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, jpeg, ExtCtrls;

type
  TForm2 = class(TForm)
    Label1: TLabel;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    ComboBox1: TComboBox;
    GroupBox2: TGroupBox;
    Label4: TLabel;
    ComboBox2: TComboBox;
    Label5: TLabel;
    ComboBox3: TComboBox;
    Image1: TImage;
    Button1: TButton;
    GroupBox3: TGroupBox;
    Memo1: TMemo;
    Button2: TButton;
    Button3: TButton;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    GroupBox4: TGroupBox;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Timer1: TTimer;
    Label17: TLabel;
    ComboBox4: TComboBox;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    RadioButton6: TRadioButton;
    RadioButton7: TRadioButton;
    RadioButton8: TRadioButton;
    RadioButton9: TRadioButton;
    RadioButton10: TRadioButton;
    RadioButton11: TRadioButton;
    RadioButton12: TRadioButton;
    RadioButton13: TRadioButton;
    RadioButton14: TRadioButton;
    RadioButton15: TRadioButton;
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure RadioButton3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);

      private
    { Private declarations }
  public
    { Public declarations }
  end;

TYPE
    timetable=RECORD
          title:string;
          departtime:integer;
          arrivaltime:integer;
          fee:integer
        END;
    lvke=RECORD
        passagename:string;
        searchtime:integer;
        departplace:integer;
        arrivalplace:integer;
        spendtime:integer
       END;
    information=ARRAY[1..12,1..12,1..3] OF timetable;
    shuzu=ARRAY [1..12,1..12]OF integer;
    lujing=ARRAY [1..20]OF integer;
var
  Form2: TForm2;
  informations:information;
  via:integer;
  depart,arrival,kk:integer;
  dist,path,cost:shuzu;
  result:string;
  shuchuhang,totalnumber:integer;
  road,road2,road3:lujing;
  path_time,path_time2:shuzu;
  passageinformation:ARRAY [1..100] OF lvke;
  implementation

{$R *.dfm}

FUNCTION  place(i:integer):string;
BEGIN
    CASE i OF
        1:place:='北京';
        2:place:='上海';
        3:place:='广州';
        4:place:='哈尔滨';
        5:place:='大连';
        6:place:='天津';
        7:place:='西安';
        8:place:='郑州';
        9:place:='杭州';
        10:place:='成都';
        11:place:='桂林';
        12:place:='拉萨';
    END
END;

FUNCTION transport(i:integer):string;
BEGIN
    CASE i OF
      1:transport:='飞机';
      2:transport:='火车';
      3:transport:='汽车';
    END;
END;

PROCEDURE  insert(VAR road:lujing;depart,arrival,k:integer);
VAR i,j:integer;
BEGIN
    j:=20;
    WHILE road[j]<>arrival DO
      j:=j-1;
    FOR i:=19 DOWNTO j DO
      road[i+1]:=road[i];
    road[j]:=k;
END;

PROCEDURE band(VAR road:lujing; road2:lujing);
VAR i,j:integer;
BEGIN
    j:=1;
    WHILE road[j]<>0 DO
      j:=j+1;
    i:=2;
    WHILE road2[i]<>0 DO
      BEGIN
          road[j]:=road2[i];
          j:=j+1;
          i:=i+1;
      END;
END;


PROCEDURE creat_path(depart,arrival:integer;path:shuzu;VAR road:lujing);
VAR k:integer;
BEGIN
    k:=path[depart,arrival];
    IF k<>0 THEN
        BEGIN
            insert(road,depart,arrival,k);
            creat_path(depart,k,path,road);
            creat_path(k,arrival,path,road);
        END;
END;

PROCEDURE minfee_FLOYD(dist:shuzu; VAR cost:shuzu; VAR path:shuzu);
VAR i,j,k:integer;
BEGIN
    FOR i:=1 TO 12 DO
        FOR j:=1 TO 12 DO
          BEGIN
            cost[i,j]:=dist[i,j];
            path[i,j]:=0;
          END;
    FOR k:=1 TO 12 DO
        FOR i:=1 TO 12 DO
            FOR j:=1 TO 12 DO
                IF cost[i,k]+cost[k,j]<cost[i,j] THEN
                    BEGIN
                      cost[i,j]:=cost[i,k]+cost[k,j];
                      path[i,j]:=k
                    END;
END;

PROCEDURE  join(VAR path_time:shuzu; vode,nextvode:integer);
VAR i:integer;
BEGIN
    i:=1;
    WHILE path_time[vode,i]<>0 DO
      BEGIN
          path_time[nextvode,i]:=path_time[vode,i];
          i:=i+1;
      END;
   path_time[nextvode,i]:=nextvode;
END;

PROCEDURE derect(VAR path_time:shuzu;depart,arrival:integer);
VAR visit:ARRAY [1..12]OF boolean;
    time:shuzu;
    i,j,derecttime,vode,nextvode,tempvode,tempnextvode,temparrivaltime:integer;
    temptime:ARRAY [1..12] OF integer;
BEGIN
    FOR i:=1 to 12 DO
        visit[i]:=false;
    visit[depart]:=true;
    FOR i:=1 TO 12 DO
        FOR j:=1 TO 12 DO
            time[i,j]:=10000;
    time[depart,depart]:=0;
    FOR i:=1 TO 12 DO
        temptime[i]:=-1;
    temptime[depart]:=strtoint(Form2.Label10.Caption);
    WHILE visit[arrival]=false DO
        BEGIN
             derecttime:=10000;
             FOR vode:=1 TO 12 DO
                FOR nextvode:=1 TO 12 DO
                    IF ((visit[vode]=true)AND(visit[nextvode]=false)) THEN
                        BEGIN
                            FOR j:=1 TO 3 DO
                                IF (time[depart,vode]+((informations[vode,nextvode,j].departtime+24-temptime[vode])mod 24)+((informations[vode,nextvode,j].arrivaltime+24-informations[vode,nextvode,j].departtime)mod 24)<derecttime)and(informations[vode,nextvode,j].departtime<>-1) THEN
                                    BEGIN
                                        derecttime:=time[depart,vode]+((informations[vode,nextvode,j].departtime+24-temptime[vode])mod 24)+((informations[vode,nextvode,j].arrivaltime+24-informations[vode,nextvode,j].departtime)mod 24);
                                        tempvode:=vode;
                                        tempnextvode:=nextvode;
                                        temparrivaltime:=informations[vode,nextvode,j].arrivaltime;
                                    END;
                        END;
             visit[tempnextvode]:=true;
             time[depart,tempnextvode]:=derecttime;
             join(path_time,tempvode,tempnextvode);
             temptime[tempnextvode]:=temparrivaltime;
        END;

END;

PROCEDURE change(VAR road3:lujing;path_time:shuzu);
VAR i:integer;
BEGIN
    i:=2;
    WHILE path_time[arrival,i]<>0 DO
        BEGIN
            road3[i]:=path_time[arrival,i];
            i:=i+1;
        END;

END;

PROCEDURE hebing(VAR road3:lujing;path_time,path_time2:shuzu);
VAR i,j:integer;
BEGIN
    i:=2;
    WHILE path_time[via,i]<>0 DO
        BEGIN
            road3[i]:=path_time[via,i];
            i:=i+1;
        END;
    j:=2;
    WHILE path_time2[arrival,j]<>0 DO
        BEGIN
            road3[i]:=path_time2[arrival,j];
            j:=j+1;
            i:=i+1;
        END;

END;


PROCEDURE output2(depart,arrival:integer;road:lujing);
VAR celue,name,tomorrow:string;
    temptime,money,choice,i,j,k,dt,art,wt,shuchuhang,totlemoney,totletime:integer;
    daoda:boolean;
BEGIN
   daoda:=false;
   i:=1;
   shuchuhang:=2;
   totlemoney:=0;
   totletime:=0;
   celue:='费用最少策略:';
   Form2.Memo1.Lines[0]:='你选择了从'+place(depart)+'到'+place(arrival)+'的'+celue;
   Form2.Memo1.Lines[1]:='现在时间是'+Form2.Label7.Caption+'年'+Form2.Label8.Caption+'月'+Form2.Label9.Caption+'日'+Form2.Label10.Caption+'时';
   temptime:=strtoint(Form2.Label10.Caption);
   WHILE daoda<>true DO
      BEGIN
          money:=10000;choice:=1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -