1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
if(Edit1->Text==' ')
{
StringGrid1->ColCount=5;
StringGrid1->RowCount=5;
StringGrid2->ColCount=5;
}
else
{
StringGrid1->ColCount=StrToInt(Edit1->Text);
StringGrid1->RowCount=StrToInt(Edit1->Text);
StringGrid2->ColCount=StrToInt(Edit1->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int f=1;
int t=1;
int a=1;
int k=1;
int i,j,min=10000;
bool bol;
i=StrToInt(Edit2->Text);
while(i<=StrToInt(Edit1->Text))
if(a<=StrToInt(Edit1->Text)+1)
{
t++;
for(j=1;j<=StrToInt(Edit1->Text);j++)
{k++;
if(StrToInt(StringGrid1->Cells[j][i])<min)
while(k<=StrToInt(Edit1->Text))
{
if(StrToInt(StringGrid2->Cells[k][1])==j)
break;
else
k++; bol=true;
if(k==StrToInt(Edit1->Text) && bol==true)
{min=StrToInt(StringGrid1->Cells[j][i]);
f=j;
}
}
}
StringGrid2->Cells[t][0]=IntToStr(f);
StringGrid2->Cells[t-1][1]=IntToStr(min);
StringGrid2->Cells[StrToInt(Edit1->Text)][1]=StringGrid1->Cells[StrToInt(Edit2->Text)][StrToInt(StringGrid2->Cells[StrToInt(Edit1->Text)][0])];
a++;
}
}
//--------------------------------------------------------------------------- |
Partager