Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. #include "math.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma resource "*.dfm"
  11. TForm1 *Form1;
  12. //---------------------------------------------------------------------------
  13. __fastcall TForm1::TForm1(TComponent* Owner)
  14. : TForm(Owner)
  15. {
  16. }
  17. //---------------------------------------------------------------------------
  18.  
  19. void __fastcall TForm1::FormCreate(TObject *Sender)
  20. {
  21. Edit1->Text="0,1";
  22. Edit2->Text="0,9";
  23. Edit3->Text="0,0001";
  24. Memo1->Clear();
  25. Memo1->Lines->Add("Результат гр 942791 Белько И.В");
  26. }
  27. //---------------------------------------------------------------------------
  28.  
  29. void __fastcall TForm1::Button1Click(TObject *Sender)
  30. {
  31. double a, b, h, s, y, e;
  32. a=StrToFloat(Edit1->Text);
  33. Memo1->Lines->Add("A="+Edit1->Text);
  34. b=StrToFloat(Edit2->Text);
  35. Memo1->Lines->Add("B="+Edit2->Text);
  36. e=StrToFloat(Edit3->Text);
  37. Memo1->Lines->Add("e="+Edit3->Text);
  38. h=(b-a)/10.;
  39. double x =a;
  40. while(x<=b)
  41. {
  42. s=0;
  43. y=log(2*cos(x/2));
  44. int n=1;
  45. do
  46. {
  47. s+= pow(-1, n-1)*cos(n*x)/n;
  48. n++;
  49. }
  50. while (fabs(y-s)>=e);
  51. n--;
  52. Memo1->Lines->Add("При x="+FloatToStrF(x,ffFixed,8,2)
  53. + " S(x)="+FloatToStrF(s,ffFixed,8,5)
  54. + " Y(x)="+FloatToStrF(y,ffFixed,8,5));
  55. x += h;
  56.  
  57. }
  58.  
  59.  
  60. }
  61. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement