Решение транспортных задач венгерским методом

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование



].ToDouble()<<" ";

}

}

f.close();

}

//------------------------------------------------------------------------TForm1::Open(UnicodeString adr)

{

int k;

double d;

ifstream f(adr.t_str() ,ios::in|ios::nocreate);

f>>k;

//UDStrok->Position=k;

f>>k;

//UDStolb->Position=k;

//Zapas->RowCount=UDStrok->Position+1;

for(int i=1;iRowCount;i++)

{

f>>d;

Zapas->Cells[0][i]=FormatFloat("",d);

}

//StoimPer->RowCount=UDStrok->Position+1;

//StoimPer->ColCount=UDStolb->Position+1;

for(int i=1;iRowCount;i++)

{

for(int j=1;jColCount;j++)

{

f>>d;

StoimPer->Cells[j][i]=FormatFloat("",d);

}

}

//Ogran->RowCount=UDStrok->Position;

//Ogran->ColCount=UDStolb->Position;

for(int i=0;iRowCount;i++)

{

for(int j=0;jColCount;j++)

{

f>>d;

Ogran->Cells[j][i]=FormatFloat("",d);

}

}

//Potr->ColCount=UDStolb->Position+1;

for(int i=1;iColCount;i++)

{

f>>d;

Potr->Cells[i][0]=FormatFloat("",d);

}

f.close();

Edit2->Text="L=";

}TForm1::NewTab()

{

Sheet=new TTabSheet(this);

Grid=new TStringGrid(this);

GrX=new TStringGrid(this);

LabelC=new TLabel(this);

LabelX=new TLabel(this);

Sheet->Parent=this;

Sheet->PageControl=PageControl;

NIter++;

Sheet->Caption="Итер. №"+IntToStr(NIter);

Sheet->Name="S"+IntToStr(NIter-1);

Grid->Parent=Sheet;

Grid->OnDrawCell=StoimPer->OnDrawCell;

Grid->Left=29;

Grid->Top=34;

Grid->Height=181;

Grid->Width=256;

Grid->DefaultColWidth=35;

Grid->DefaultRowHeight=24;

Grid->FixedCols=0;

Grid->FixedRows=0;

Grid->ScrollBars=ssNone;

Grid->RowCount=Cn;

Grid->ColCount=Cm;

for(int i=0;i<Cn;i++)

{

for(int j=0;j<Cm;j++)

{

switch (N[i][j])

{

case 4:

Grid->Cells[j][i]="0*";

break;

case 3:

Grid->Cells[j][i]="0'";

break;

case 2:

Grid->Cells[j][i]=L'\u022a';

break;

case 1:

Grid->Cells[j][i]=L'\u0230';

break;

case 0:

Grid->Cells[j][i]="0";

case -1:

Grid->Cells[j][i]=FormatFloat("",C[i][j]/100.0);

break;

}

}

}

LabelC->Parent=Sheet;

LabelC->Left=17;

LabelC->Top=18;

LabelC->Caption="C"+IntToStr(NIter);

GrX->Parent=Sheet;

GrX->Left=29;

GrX->Top=221;

GrX->Height=181;

GrX->Width=256;

GrX->DefaultColWidth=35;

GrX->DefaultRowHeight=24;

GrX->FixedCols=0;

GrX->FixedRows=0;

GrX->ScrollBars=ssNone;

GrX->RowCount=Cn;

GrX->ColCount=Cm;

for(int i=0;i<Cn;i++)

for(int j=0;j<Cm;j++)

if(X[i][j]!=0)

GrX->Cells[j][i]=FormatFloat("",X[i][j]/100.0);

LabelX->Parent=Sheet;

LabelX->Left=17;

LabelX->Top=200;

LabelX->Caption="X"+IntToStr(NIter);

TStringGrid *GridP=new TStringGrid(this);

GridP->Parent=Sheet;

GridP->Left=286;

GridP->Top=221;

GridP->Height=181;

GridP->Width=39;

GridP->ColCount=1;

GridP->DefaultColWidth=35;

GridP->DefaultRowHeight=24;

GridP->FixedCols=0;

GridP->FixedRows=0;

GridP->RowCount=Cn;

GridP->ScrollBars=ssNone;

for(int i=0;i<Cn;i++)

GridP->Cells[0][i]=FormatFloat("",Z[i]/100.0);

TStringGrid* GridB=new TStringGrid(this);

GridB->Parent=Sheet;

GridB->Left=30;

GridB->Top=405

;

GridB->Height=25;

GridB->Width=256;

GridB->ColCount=Cm;

GridB->DefaultColWidth=35;

GridB->DefaultRowHeight=24;

GridB->FixedCols=0;

GridB->FixedRows=0;

GridB->RowCount=1;

GridB->ScrollBars=ssNone;

for(int i=0;i<Cm;i++)

GridB->Cells[i][0]=FormatFloat("",P[i]/100.0);

GridF=new TStringGrid(this);

GridF->Parent=Sheet;

GridF->Left=286;

GridF->Top=34;

GridF->Height=181;

GridF->Width=16;

GridF->ColCount=1;

GridF->DefaultColWidth=12;

GridF->DefaultRowHeight=24;

GridF->FixedCols=0;

GridF->FixedRows=0;

GridF->RowCount=Cn;

GridF->ScrollBars=ssNone;

for(int i=0;i<Cn;i++)

if(F[i]==1)

GridF->Cells[0][i]="+";

TStringGrid *GridG=new TStringGrid(this);

GridG->Parent=Sheet;

GridG->Left=30;

GridG->Top=13;

GridG->Height=16;

GridG->Width=256;

GridG->ColCount=Cm;

GridG->DefaultColWidth=35;

GridG->DefaultRowHeight=12;

GridG->FixedCols=0;

GridG->FixedRows=0;

GridG->RowCount=1;

GridG->ScrollBars=ssNone;

for(int i=0;i<Cm;i++)

if(G[i]==1)

GridG->Cells[i][0]="+";

}TForm1::Predv()

{

Sheet=new TTabSheet(this);

Grid=new TStringGrid(this);

GrX=new TStringGrid(this);

LabelC=new TLabel(this);

LabelX=new TLabel(this);

Sheet->Parent=this;

Sheet->PageControl=PageControl;

Sheet->Caption="Предв. этап";

Grid->Parent=Sheet;

Grid->Left=30;

Grid->Top=39;

Grid->Height=181;

Grid->Width=256;

Grid->DefaultColWidth=35;

Grid->DefaultRowHeight=24;

Grid->FixedCols=0;

Grid->FixedRows=0;

Grid->ScrollBars=ssNone;

Grid->RowCount=Cn;

Grid->ColCount=Cm;

for(int i=0;i<Cn;i++)

{

for(int j=0;j<Cm;j++)

{

Grid->Cells[j][i]=FormatFloat("",CS[i][j]/100.0);

}

}

LabelC->Parent=Sheet;

LabelC->Left=3;

LabelC->Top=20;

LabelC->Caption="C'";

GrX->Parent=Sheet;

GrX->Left=30;

GrX->Top=239;

GrX->Height=181;

GrX->Width=256;

GrX->DefaultColWidth=35;

GrX->DefaultRowHeight=24;

GrX->FixedCols=0;

GrX->FixedRows=0;

GrX->ScrollBars=ssNone;

GrX->RowCount=Cn;

GrX->ColCount=Cm;

for(int i=0;i<Cn;i++)

for(int j=0;j<Cm;j++)

GrX->Cells[j][i]=FormatFloat("",C[i][j]/100.0);

LabelX->Parent=Sheet;

LabelX->Left=3;

LabelX->Top=223;

LabelX->Caption="C0";

}TForm1::Ecviv()

{

Sheet=new TTabSheet(this);

Grid=new TStringGrid(this);

LabelC=new TLabel(this);

Sheet->Parent=this;

Sheet->PageControl=PageControl;

NKor++;

Sheet->Caption="Экв. пр. №"+IntToStr(NIter+1)+"."+IntToStr(NKor);

Grid->Parent=Sheet;

Grid->Left=30;

Grid->Top=39;

Grid->Height=181;

Grid->Width=256;

Grid->DefaultColWidth=35;

Grid->DefaultRowHeight=24;

Grid->FixedCols=0;

Grid->FixedRows=0;

Grid->ScrollBars=ssNone;

Grid->RowCount=Cn;

Grid->ColCount=Cm;

for(int i=0;i<Cn;i++)

{

for(int j=0;j<Cm;j++)

{

switch (N[i][j])

{

case 4:

Grid->Cells[j][i]="0*";

break;

case 3:

Grid->Cells[j][i]="0'";

break;

case 2:

Grid->Cells[j][i]=L'\u022a';

break;

case 1:

Grid->Cells[j][i]=L'\u0230';

break;

case 0:

Grid->Cells[j][i]="0";

case -1:

Grid->Cells[j][i]=FormatFloat("",C[i][j]/100.0);

break;

}

}

}

LabelC->Parent=Sheet;

LabelC->Left=3;

LabelC->Top=20;

LabelC->Caption="C"+IntToStr(NKor);

}__fastcall TForm1::CepochDrawCell(TObject *Sender, int ACol, int ARow, TRect &Rect,

TGridDrawState State)

{

TStringGrid* c=(TStringGrid*) Sender;

if (c->Name!="StoimPer")

{

UnicodeString Index;

Index=PageControl->ActivePage->Name;

Index.Delete(1,1);

nomer=Index.ToInt();

Graphics::TBitmap *pict = new Graphics::TBitmap();

switch (Cep[nomer][ARow][ACol])

{

case 12:

pict->LoadFromResourceID((unsigned int)HInstance,104);

break;

case 9:

pict->LoadFromResourceID((unsigned int)HInstance,102);

break;

case 7:

pict->LoadFromResourceID((unsigned int)HInstance,106);

break;

case 6:

pict->LoadFromResourceID((unsigned int)HInstance,105);

break;

case 5:

pict->LoadFromResourceID((unsigned int)HInstance,108);

break;

case 4:

pict-&g