__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
srand(time(NULL));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i,j,k,width,height;
width=5; height=2;
float tab[width][height],r,d=10.0,scalar_Product;
for(i=0;i<width;i++)
{
for(j=0;j<height;j++)
{
k=1+rand()%100;
r=(1.00*k)/d;
tab[i][j]=r;
StringGrid1->Cells[i][j]=FloatToStrF(tab[i][j],ffGeneral,4,4);
}
}
std::valarray<float> x {tab[0][0],tab[0][1], tab[0][2], tab[0][3], tab[0][4]};
std::valarray<float> y {tab[1][0],tab[1][1], tab[1][2], tab[1][3], tab[1][4]};
scalar_Product=(x*y).sum();
Label1->Caption="SCALAR PRODUCT = "+FloatToStr(scalar_Product);
}
Brak komentarzy:
Prześlij komentarz