//---------------------------------------------------------------------------
#include<math.h>
#include <vcl.h>
#pragma hdrstop
#include "Mybible.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
for (int i=1;i<=k;i++)
{
SG1->Cells[0][i]="строка №"+IntToStr(i);
SG1->Cells[i][0]="столбец №"+IntToStr(i);
SG2->Cells[0][i-1]="Эл-т №"+IntToStr(i); }
}
//---------------------------------------------------------------------------
matr a; vect x;
void __fastcall TForm1::Button4Click(TObject *Sender){ Close();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int i,j;
for (i=0;i<=k;i++)
for (j=0;j<=k;j++)
SG1->Cells[j+1][i+1]=" ";
for (i=0;i<=k;i++)
SG2->Cells[1][i]="";
Edit1->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
double g=0;
g=funG(x);
Edit1->Text=FormatFloat("0.000",g);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
elemVect(a,x);
for (int i=0; i<k;i++)
SG2->Cells[1][i]=FormatFloat("0.000",x[i]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
elemMatr (a);
int i,j;
for (i=0;i<k;i++)
for (j=0;j<k;j++)
SG1->Cells[j+1][i+1]=FormatFloat("0.000", a[i][j]);
Button2->Visible=1;
Button3->Visible=1;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef MybibleH
#define MybibleH
//---------------------------------------------------------------------------
const int k=6;
typedef double matr[k][k];
typedef double vect[k];
void elemMatr(matr c);
void elemVect(matr c, vect v);
double funG(vect c);
void elemMatr (matr c){
int i, j;
for(i=0;i<k; i++)
for(j=0;j<k; j++)
c[i][j]=sqrt(i+5)*2*pow((j+1),-2)-abs(i+j-4);
}
void elemVect (matr c, vect v)
{
int i, j;
for(i=0;i<k;i++)
{
v[i]=0;
double b=1;
for (j=0;j<k;j++){
if(c[i][j]>0){
b*=c[i][j];
v[i]=b;
}
}
}
}
double funG(vect x)
{
int i,j; double a, g;
g=0;
for (i=0;i<4;i++)
{
a=1;
for (j=0;j<=i;j++) a*=x[j]+log(x[j]);
g+=x[j]/a;
}
return g;
}
#endif