#define size_FL 36
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
srand(time(NULL));
}
//---------------------------------------------------------------------------
int min_Array(int a, int b)
{
if(a<b)
return a;
else
return b;
}
int max_Array(int a, int b)
{
if(a>b)
return a;
else
return b;
}
void __fastcall TForm1::init_minus_One(int **tab, int t_Size)
{
for(int i=0;i<t_Size;i++)
for(int j=0;j<t_Size;j++)
tab[i][j]=-1;
}
void __fastcall TForm1::init_temp_Zero(int *tab, int t_Size)
{
for(int i=0;i<t_Size;i++)
tab[i]=0;
}
void __fastcall TForm1::min_Floyd(int **tab, int size)
{
int i,j,k;
for(i=0;i<size;i++)
for(j=0;j<size;j++)
for(k=0;k<size;k++)
tab[j][k]=min_Array(tab[j][k],tab[j][i]+tab[i][k]);
}
void __fastcall TForm1::max_Floyd(int **tab, int size)
{
int i,j,k;
for(i=0;i<size;i++)
for(j=0;j<size;j++)
for(k=0;k<size;k++)
tab[j][k]=max_Array(tab[j][k],tab[j][i]+tab[i][k]);
}
void __fastcall max_Floyd(int **tab, int size);
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i,j,k,random_V;
int **FLOYD_TABLE;
int *temp_table_X;
int *temp_table_Y;
FLOYD_TABLE=new int *[size_FL];
for(i=0;i<size_FL;i++)
FLOYD_TABLE[i]=new int[size_FL];
temp_table_X=new int[size_FL];
temp_table_Y=new int[size_FL];
init_minus_One(FLOYD_TABLE,size_FL);
init_temp_Zero(temp_table_Y,size_FL);
init_temp_Zero(temp_table_X,size_FL);
random_V=rand()%(64-16)+16;
Edit1->Text="RANDOM VALUES TABLE= "+IntToStr(random_V);
i=0;
do
{
j=rand()%size_FL;
if(temp_table_X[j]==0)
{
temp_table_X[j]=1;
++i;
}
}while(i<random_V);
i=0;
do
{
j=rand()%size_FL;
if(temp_table_Y[j]==0)
{
temp_table_Y[j]=1;
++i;
}
}while(i<random_V);
int *index_X,*index_Y;
index_X=new int[random_V];
index_Y=new int[random_V];
i=0;
j=0;
do
{
if(temp_table_X[j]==1)
{
index_X[i]=j;
++i;
}
++j;
}while(i<random_V);
i=0;
j=0;
do
{
if(temp_table_Y[j]==1)
{
index_Y[i]=j;
++i;
}
++j;
}while(i<random_V);
for(i=0;i<random_V;i++)
{
FLOYD_TABLE[index_X[i]][index_Y[i]]=rand()%(360-10)+10;
}
for(i=0;i<size_FL;i++)
for(j=0;j<size_FL;j++)
StringGrid1->Cells[j][i]=IntToStr(FLOYD_TABLE[i][j]);
int **FLOYD_MAX;
int **FLOYD_MIN;
FLOYD_MIN=new int *[size_FL];
FLOYD_MAX=new int *[size_FL];
for(i=0;i<size_FL;i++)
{
FLOYD_MAX[i]=new int[size_FL];
FLOYD_MIN[i]=new int[size_FL];
}
for(i=0;i<size_FL;i++)
{
for(j=0;j<size_FL;j++)
{
FLOYD_MAX[i][j]=FLOYD_TABLE[i][j];
FLOYD_MIN[i][j]=FLOYD_TABLE[i][j];
}
}
min_Floyd(FLOYD_MIN,size_FL);
max_Floyd(FLOYD_MAX,size_FL);
for(i=0;i<size_FL;i++)
{
for(j=0;j<size_FL;j++)
{
if(FLOYD_MIN[i][j]!=-1 && i!=j)
ListBox1->Items->Add(IntToStr(i)+"--->"+IntToStr(j)+" = "+IntToStr(FLOYD_MIN[i][j]));
}
}
for(i=0;i<size_FL;i++)
{
for(j=0;j<size_FL;j++)
{
if(FLOYD_MAX[i][j]!=-1 && i!=j)
ListBox2->Items->Add(IntToStr(i)+"--->"+IntToStr(j)+" = "+IntToStr(FLOYD_MAX[i][j]));
}
}
for(i=0;i<size_FL;i++)
{
delete FLOYD_TABLE[i];
delete FLOYD_MIN[i];
delete FLOYD_MAX[i];
}
delete [] FLOYD_TABLE;
delete [] FLOYD_MIN;
delete [] FLOYD_MAX;
delete temp_table_X;
delete temp_table_Y;
delete index_X;
delete index_Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
srand(time(NULL));
}
//---------------------------------------------------------------------------
int min_Array(int a, int b)
{
if(a<b)
return a;
else
return b;
}
int max_Array(int a, int b)
{
if(a>b)
return a;
else
return b;
}
void __fastcall TForm1::init_minus_One(int **tab, int t_Size)
{
for(int i=0;i<t_Size;i++)
for(int j=0;j<t_Size;j++)
tab[i][j]=-1;
}
void __fastcall TForm1::init_temp_Zero(int *tab, int t_Size)
{
for(int i=0;i<t_Size;i++)
tab[i]=0;
}
void __fastcall TForm1::min_Floyd(int **tab, int size)
{
int i,j,k;
for(i=0;i<size;i++)
for(j=0;j<size;j++)
for(k=0;k<size;k++)
tab[j][k]=min_Array(tab[j][k],tab[j][i]+tab[i][k]);
}
void __fastcall TForm1::max_Floyd(int **tab, int size)
{
int i,j,k;
for(i=0;i<size;i++)
for(j=0;j<size;j++)
for(k=0;k<size;k++)
tab[j][k]=max_Array(tab[j][k],tab[j][i]+tab[i][k]);
}
void __fastcall max_Floyd(int **tab, int size);
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i,j,k,random_V;
int **FLOYD_TABLE;
int *temp_table_X;
int *temp_table_Y;
FLOYD_TABLE=new int *[size_FL];
for(i=0;i<size_FL;i++)
FLOYD_TABLE[i]=new int[size_FL];
temp_table_X=new int[size_FL];
temp_table_Y=new int[size_FL];
init_minus_One(FLOYD_TABLE,size_FL);
init_temp_Zero(temp_table_Y,size_FL);
init_temp_Zero(temp_table_X,size_FL);
random_V=rand()%(64-16)+16;
Edit1->Text="RANDOM VALUES TABLE= "+IntToStr(random_V);
i=0;
do
{
j=rand()%size_FL;
if(temp_table_X[j]==0)
{
temp_table_X[j]=1;
++i;
}
}while(i<random_V);
i=0;
do
{
j=rand()%size_FL;
if(temp_table_Y[j]==0)
{
temp_table_Y[j]=1;
++i;
}
}while(i<random_V);
int *index_X,*index_Y;
index_X=new int[random_V];
index_Y=new int[random_V];
i=0;
j=0;
do
{
if(temp_table_X[j]==1)
{
index_X[i]=j;
++i;
}
++j;
}while(i<random_V);
i=0;
j=0;
do
{
if(temp_table_Y[j]==1)
{
index_Y[i]=j;
++i;
}
++j;
}while(i<random_V);
for(i=0;i<random_V;i++)
{
FLOYD_TABLE[index_X[i]][index_Y[i]]=rand()%(360-10)+10;
}
for(i=0;i<size_FL;i++)
for(j=0;j<size_FL;j++)
StringGrid1->Cells[j][i]=IntToStr(FLOYD_TABLE[i][j]);
int **FLOYD_MAX;
int **FLOYD_MIN;
FLOYD_MIN=new int *[size_FL];
FLOYD_MAX=new int *[size_FL];
for(i=0;i<size_FL;i++)
{
FLOYD_MAX[i]=new int[size_FL];
FLOYD_MIN[i]=new int[size_FL];
}
for(i=0;i<size_FL;i++)
{
for(j=0;j<size_FL;j++)
{
FLOYD_MAX[i][j]=FLOYD_TABLE[i][j];
FLOYD_MIN[i][j]=FLOYD_TABLE[i][j];
}
}
min_Floyd(FLOYD_MIN,size_FL);
max_Floyd(FLOYD_MAX,size_FL);
for(i=0;i<size_FL;i++)
{
for(j=0;j<size_FL;j++)
{
if(FLOYD_MIN[i][j]!=-1 && i!=j)
ListBox1->Items->Add(IntToStr(i)+"--->"+IntToStr(j)+" = "+IntToStr(FLOYD_MIN[i][j]));
}
}
for(i=0;i<size_FL;i++)
{
for(j=0;j<size_FL;j++)
{
if(FLOYD_MAX[i][j]!=-1 && i!=j)
ListBox2->Items->Add(IntToStr(i)+"--->"+IntToStr(j)+" = "+IntToStr(FLOYD_MAX[i][j]));
}
}
for(i=0;i<size_FL;i++)
{
delete FLOYD_TABLE[i];
delete FLOYD_MIN[i];
delete FLOYD_MAX[i];
}
delete [] FLOYD_TABLE;
delete [] FLOYD_MIN;
delete [] FLOYD_MAX;
delete temp_table_X;
delete temp_table_Y;
delete index_X;
delete index_Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
YOU CAN PAY ME - https://paypal.me/LukaszW77?locale.x=pl_PL