Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- #include "math.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Edit1->Text="0,1";
- Edit2->Text="0,9";
- Edit3->Text="0,0001";
- Memo1->Clear();
- Memo1->Lines->Add("Результат гр 942791 Белько И.В");
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- double a, b, h, s, y, e;
- a=StrToFloat(Edit1->Text);
- Memo1->Lines->Add("A="+Edit1->Text);
- b=StrToFloat(Edit2->Text);
- Memo1->Lines->Add("B="+Edit2->Text);
- e=StrToFloat(Edit3->Text);
- Memo1->Lines->Add("e="+Edit3->Text);
- h=(b-a)/10.;
- double x =a;
- while(x<=b)
- {
- s=0;
- y=log(2*cos(x/2));
- int n=1;
- do
- {
- s+= pow(-1, n-1)*cos(n*x)/n;
- n++;
- }
- while (fabs(y-s)>=e);
- n--;
- Memo1->Lines->Add("При x="+FloatToStrF(x,ffFixed,8,2)
- + " S(x)="+FloatToStrF(s,ffFixed,8,5)
- + " Y(x)="+FloatToStrF(y,ffFixed,8,5));
- x += h;
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement