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

📄 pert2.pas

📁 用delphi语言实现运筹学网络计划自动编号程序程序
💻 PAS
字号:
unit Pert2;
      interface
     uses
  Windows, Messages, SysUtils, Variants, ClasSEs, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, Grids;

type
  TForm1 = class(TForm)
    Panel2: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    BitBTN1: TBitBTN;
    BitBTN3: TBitBTN;
    CheckBox1: TCheckBox;
    Panel3: TPanel;
    Panel1: TPanel;
    BitBtn2: TBitBtn;
    BitBtn4: TBitBtn;
    Label3: TLabel;
    StringGrid3: TStringGrid;
    Label4: TLabel;
    Label5: TLabel;
    Label2: TLabel;
    Label6: TLabel;
    procedure BitBTN1Click(SEnder: TObject);
    procedure BitBTN3Click(SEnder: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
  privaTE
    { PrivaTE declarations }
  public
    { Public declarations }
  end;
type array2=array[1..99,1..99] of real;  //声明的数组类型数据:二维数组
var
  Form1: TForm1;
implementation
var CheckBox:array of array of TCheckBox;
var BHSC,edt,edit:array of array of TEdit;
var CC:array[1..99,1..99]of Integer;
//var szhs,FF:array[1..99]of real;
var qsjh,hsjh:array[1..99]of string;
var FJBH,FJJGSHU,FJJG:array[1..99]of Integer;
//var szhs:array of integer;
var TT,MAXFJJG,T,MM,KK,H,k,N,hangshu,hangshu1,hangshu2,hangshu3:InTEger;
{$R *.dfm}
procedure TForm1.BitBTN1Click(SEnder: TObject);
var  i,j:inTEger;
begin
//创建事件名称输入编辑框
  if edit<>nil then
    for i:=0 to hangshu1-1 do
      for j:=0 to 0 do
        edit[i,j].Free;
  hangshu1:=StrToInt(Edit1.TExt);
  SETLength(edit,hangshu1);
  for i:=low(edit) to high(edit) do
    SETLength(edit[i],1);
  for i:=low(edit) to high(edit) do
     for j:=0 to 0 do
       begin
         edit[i,j]:=TEdit.CreaTE(SElf);
         with edit[i,j] do
           begin
              Parent:=Panel1;
              Width:=25;
              Height:=25;
              left:=40+j*40;
              top:=65+i*40;
           end;
       end;
//创建紧前事件自动生成编辑框
  if edt<>nil then
     for j:=0 to hangshu2-1 do
        edt[0,j].Free;
  hangshu2:=StrToInt(Edit1.TExt);
  SETLength(edt,hangshu2);
  for J:=low(edt) to high(edt) do
    SETLength(edt[J],hangshu2);
    for j:=low(edt) to high(edt) do
       begin
         edt[0,j]:=TEdit.CreaTE(SElf);
         with edt[0,j] do
           begin
              Parent:=Panel1;
              Width:=25;
              Height:=25;
              left:=85+j*40;
              top:=30;
           end;
       end;
//创建紧前工作人工选择输入框
  if CheckBox<>nil then
    for i:=0 to hangshu-1 do
      for j:=0 to hangshu-1 do
        CheckBox[i,j].Free;
  hangshu:=StrToInt(Edit1.TExt);
  SETLength(CheckBox,hangshu);
  for i:=low(CheckBox) to high(CheckBox) do
    SETLength(CheckBox[i],hangshu);
  for i:=low(CheckBox) to high(CheckBox) do
     for j:=0 to hangshu-1 do
       begin
         CheckBox[i,j]:=TCheckBox.CreaTE(SElf);
         with CheckBox[i,j] do
           begin
              Parent:=Panel1;
              left:=90+j*40;
              top:=70+i*40;
           end;
       end;
    label5.Caption:='在'+#13+'第'+#13+'一'+#13+'列'+#13+'输'
               +#13+'入'+#13+'工'+#13+'序'+#13+'名'+#13+'称';
end;procedure TForm1.BitBTN3Click(SEnder: TObject);
begin
  cloSE;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var  i,j:inTEger;
label 1;
begin
 for i:=0 to hangshu-1 do
     edt[0,I].TExt:=edit[i,0].TExt;
  label4.Caption:='工序分级结果';
  n:=strtoint(edit1.Text);  //n为变量的个数.它比对策矩阵的行数(或列数)多1
  stringgrid3.RowCount:=5;
  stringgrid3.ColCount:=n+1;
  label2.Caption:='工序编号结果';
  label6.Caption:=' 工序名称    |紧前事件号 | 紧后事件号';
//计算分级过程
//第一步找0级事件
  for i:=1 to n do
    for j:=1 to n do
      if CheckBox[i-1,j-1].Checked then
        CC[j,i]:=1
        else CC[j,i]:=0;

  for i:=1 to n do
    begin
      FJJG[i]:=0;
      for j:=1 to n do
        if CC[j,i]=1  then FJJG[i]:=-1;
    end;

//任一目工序的紧后作业,其级次比该目标作业增加1级。
1: i:=1;
   while i<n+1 do
     begin
       for j:=1 to n do
         if (CC[j,i]=1) and (FJJG[j]>=FJJG[i]) then
           FJJG[i]:=FJJG[j]+1;
       i:=i+1;
     end;
   for i:=1 to n do
     for j:=1 to n do
       if (CC[j,i]=1) and ((FJJG[j]=-1) or (FJJG[j]>=FJJG[i])) then
         goto 1;
  for i:=1 to n do
    begin
      stringgrid3.cells[i,0]:=edt[0,I-1].TExt;
      stringgrid3.Cells[0,1]:='分级结果';
      stringgrid3.Cells[0,2]:='级     别';
      stringgrid3.Cells[0,0]:='工序名称';
      stringgrid3.Cells[0,3]:='工序个数';
      stringgrid3.Cells[0,4]:='工序终点号';
      stringgrid3.Cells[i,1]:=floattostr(FJJG[i]);
    end;
  stringgrid3.refresh;
//找到最大级数MAXFJJG
  MAXFJJG:=0;
  for i:=1 to n do
    if FJJG[i]>=MAXFJJG then  MAXFJJG:=FJJG[i];
//统计各级工序的数量
  for i:=1 to MAXFJJG+1 do
    begin
      FJJGSHU[i]:=0;
      for j:=1 to n do
        if FJJG[j]=i-1 then FJJGSHU[i]:=FJJGSHU[i]+1;
    end;
//对各所有的工序进行第一轮编号
   for i:=1 to n do
     FJBH[i]:=0;
   KK:=N+1;
   for j:=0 to MAXFJJG do
     begin
       K:=MAXFJJG-j;
       for i:=1 to n do
         begin
           if FJJG[i]=k then FJBH[i]:=KK;
         end;
       KK:=KK-FJJGSHU[k];
     end;
//对各个级别的工序进行再编号
  for k:=0 to  MAXFJJG do
    begin
      for i:=2 to FJJGSHU[k+1] do
        begin
          TT:=0;
          for j:=1 to n do
            begin
              if (TT<>0) and (FJJG[j]=K) then FJBH[j]:=FJBH[j]+1;
              if FJJG[j]=K then TT:=TT+1;
            end;
        end;
    end;
//输出统计结果
  for i:=1  to MAXFJJG+1 do
    begin
      stringgrid3.Cells[i,2]:=inttostr(i-1)+'级';
      stringgrid3.Cells[i,3]:=inttostr(FJJGSHU[i]);
    end;
  for i:=1 to n do
    stringgrid3.Cells[i,4]:=inttostr(FJBH[i]);
   stringgrid3.refresh;
//创建结点编号输出框
  if BHSC<>nil then
    for i:=0 to hangshu3-1 do
      for j:=0 to 0 do
        BHSC[i,j].Free;
  hangshu3:=StrToInt(Edit1.TExt);
  SETLength(BHSC,hangshu3);
  for i:=low(BHSC) to high(BHSC) do
    SETLength(BHSC[i],3);
  for i:=low(edit) to high(edit) do
     for j:=0 to 2 do
       begin
         BHSC[i,j]:=TEdit.CreaTE(SElf);
         with BHSC[i,j] do
           begin
              Parent:=Panel3;
              Width:=80;
              Height:=25;
              left:=50+j*80;
              top:=250+i*30;
           end;
       end;
//输出编号结果
  for i:=1 to n do
    qsjh[i]:='';
  for i:=1 to n do
    if FJJG[i]=0 then qsjh[i]:='1';

  for i:=2 to n do
    hsjh[i]:='';

  T:=8;
   for i:=1 to n do
     if FJJG[i]=MAXFJJG then hsjh[i]:=inttostr(T);
  for i:=1 to n do
    begin
      for j:=1 to n do
        begin
          if CC[j,I]=1 then qsjh[i]:=inttostr(FJBH[j]);
          if CC[j,i]=1 then hsjh[i]:=inttostr(FJBH[i]);
        end;
    end;
  for i:=1 to n do
    if FJJG[i]=0 then qsjh[i]:='1';
      MM:=1;
  for i:=1 to n do
    begin
      if FJJG[i]=0 then MM:=MM+1;
      if FJJG[i]=0 then hsjh[i]:=inttostr(MM);
    end;
//输出工序名称
  for i:=0 to hangshu-1 do
     BHSC[i,0].TExt:=edit[i,0].TExt;
//输出工序紧前事件编号
  for i:=1 to n do
      begin
        BHSC[i-1,1].text:=qsjh[i];
        BHSC[i-1,2].text:=hsjh[i];
      end;
end;

procedure TForm1.BitBtn4Click(Sender: TObject);
var  i:inTEger;
begin

 for i:=0 to hangshu-1 do
     edt[0,I].TExt:=edit[i,0].TExt;
 end;

end.

⌨️ 快捷键说明

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