ZAPISYWANIE I WCZYTYWANIE
{
randomize();
for (int i=0; i<3; i++)
for (int j=0; j<3; j++)
{
Tab1 [i][j] = rand();
sgTab1 -> Cells[i+1][j+1]=FloatToStr(Tab1[i][j]);
}
}
void __fastcall TForm1::acWypTab2Execute(TObject *Sender)
{
randomize();
for (int i=0; i<3; i++)
for (int j=0; j<3; j++)
{
Tab2 [i][j] = rand();
sgTab2 -> Cells[i+1][j+1]=FloatToStr(Tab2[i][j]);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm1::acObliczExecute(TObject *Sender)
{
switch(rgObliczenia->ItemIndex)
{
case 0:
{
for (int i=0;i<3;i++)
for (int j=0;j<3;j++)
{
Tab3[i][j] = Tab1[i][j] + Tab2[i][j];
sgTab3->Cells[i+1][j+1]= FloatToStr(Tab3[i][j]);
}
break;
}
case 1:
{
for (int i=0;i<3;i++)
for (int j=0;j<3;j++)
{
Tab3[i][j] = Tab1[i][j] - Tab2[i][j];
sgTab3->Cells[i+1][j+1]= FloatToStr(Tab3[i][j]);
}
break;
}
case 2:
{
for (int i=0;i<3;i++)
for (int j=0;j<3;j++)
{
Tab3[i][j] = Tab1[i][j] * Tab2[i][j];
sgTab3->Cells[i+1][j+1]= FloatToStr(Tab3[i][j]);
}
break;
}
case 3:
{
for (int i=0;i<3;i++)
for (int j=0;j<3;j++)
{
Tab3[i][j] = Tab1[i][j] / Tab2[i][j];
sgTab3->Cells[i+1][j+1]= FloatToStr(Tab3[i][j]);
}
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ZapisywanieExecute(TObject *Sender)
{
fstream PlikWy;
PlikWy.open("Dane z tablic.txt",ios::out);
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
PlikWy<<Tab1[i][j]<<" ";
PlikWy<<endl;
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
PlikWy<<Tab2[i][j]<<" ";
PlikWy<<endl;
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
PlikWy<<Tab3[i][j]<<" ";
PlikWy<<endl;
}
PlikWy.close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Action1Execute(TObject *Sender)
{
int i=0;
int j=0;
fstream PlikWe;
PlikWe.open("Dane z tablic.txt",ios::in);
while (PlikWe)
{
PlikWe>>Tab3[i][j];
sgTab3->Cells[i+1][j+1]= FloatToStr(Tab3[i][j]);
if (j<2) j++;
else
{
i++;
j=0;
}
//sgTab3->Cells[i+1][j+1]= FloatToStr(Tab3[i][j]);
}
PlikWe.close();
}
//---------------------------------------------------------------------------
RÓWNANIE KWADRATOWE
{
double a;
a = StrToFloat(edWspA->Text);
double b;
b = StrToFloat(edWspB->Text);
double c;
c = StrToFloat(edWspC->Text);
double delta;
delta = b*b-4*a*c;
if (a!=0)
{
double delta;
delta=(b*b)-(4*a*c);
lbX3->Caption="delta="+FloatToStr(delta);
if (delta>0)
{
double X1,X2;
X1 = (-b-sqrt(delta))/(2*a);
X2 = (-b+sqrt(delta))/(2*a);
lbX1->Caption="X1="+FloatToStr(X1);
lbX2->Caption="X2="+FloatToStr(X2);
}
else
if (delta == 0)
{
double X0;
X0 = (-b)/(2*a);
lbX1->Caption="X0="+FloatToStr(X0);
lbX2->Caption="Nic";
}
else
{
lbX1->Caption="Delta jest mniejsza od zera";
double t;
t=abs(delta);
double t1;
t1=sqrt(t);
double xt1,xt2,yt1,yt2;
xt1=sqrt(t1);
xt2=sqrt(t1)*(-1);
yt1=-2/xt1;
yt2=-2/xt2;
lbX2->Caption="Wynik w liczbach zespolonych:";
lbX4->Visible=True;
lbX5->Visible=True;
lbX4->Caption="x1="+FloatToStr(xt1)+" +j("+FloatToStr(yt1)+")";
lbX5->Caption="x2="+FloatToStr(xt2)+" +j("+FloatToStr(yt2)+")";
}
}
else
{
lbX1->Caption="Podano współczynnik a równy zero!";
lbX2->Caption="";
} ;
GRAFIKA
switch(rgFigury->ItemIndex)
{
case 0:
{
for(int i=0; i<seLF->Value; i++)
{
pbRys->Canvas->Pen->Color=RGB(random(255),random(255),random(255));
pbRys->Canvas->Brush->Color=RGB(random(255),random(255),random(255));
pbRys->Canvas->Rectangle(random(pbRys->ClientWidth),random(pbRys->ClientHeight),random(pbRys->ClientWidth),random(pbRys->ClientHeight));
}
break;
}
case 1:
{
for(int i=0; i<seLF->Value; i++)
{
pbRys->Canvas->Pen->Color=RGB(random(255),random(255),random(255));
pbRys->Canvas->Brush->Color=RGB(random(255),random(255),random(255));
pbRys->Canvas->Ellipse(random(pbRys->ClientWidth),random(pbRys->ClientHeight),random(pbRys->ClientWidth),random(pbRys->ClientHeight));
}
break;
}
case 2:
{
for(int i=0;i<seLF->Value;i++)
{
pbRys->Canvas->Pen->Color=RGB(random(255),random(255),random(255));
pbRys->Canvas->Brush->Color=RGB(random(255),random(255),random(255));
int x1=random(pbRys->ClientWidth);
int y1=random(pbRys->ClientHeight);
float a=(pbRys->ClientWidth-x1);
float b=(pbRys->ClientHeight-y1);
int z;
if (a>=b)
{
z=random(pbRys->ClientHeight-y1);
}
else
{
z=random(pbRys->ClientWidth-x1);
}
pbRys->Canvas->Ellipse(x1,y1,x1+z,y1+z);
}
break ;
}
case 3:
{
for(int i=0;i<seLF->Value;i++)
{
pbRys->Canvas->Pen->Color=RGB(random(255),random(255),random(255));
pbRys->Canvas->Brush->Color=RGB(random(255),random(255),random(255));
TPoint Punkt[3];
Punkt[0]=TPoint(random(pbRys->ClientWidth),random(pbRys->ClientHeight));
Punkt[1]=TPoint(random(pbRys->ClientWidth),random(pbRys->ClientHeight));
Punkt[2]=TPoint(random(pbRys->ClientWidth),random(pbRys->ClientHeight));
pbRys->Canvas->Polygon(Punkt,3);
}
break ;
}
}
}