Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 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="1,e-5";
  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=sin(x)/x;
  44. int n=0;
  45. do
  46. {
  47. double f=1 ;
  48. for (int i = 1; i <= 2*n+1; i++)
  49. {
  50. f*=i;
  51. }
  52. s+= pow(-1, n)*pow(x, 2*n)/f;
  53. n++;
  54. }
  55. while (fabs(y-s)>=e);
  56. n--;
  57. Memo1->Lines->Add("Ïðè x="+FloatToStrF(x,ffFixed,8,2)
  58. + " S(x)="+FloatToStrF(s,ffFixed,8,2)
  59. + " Y(x)="+FloatToStrF(y,ffFixed,8,2)
  60. + " n="+IntToStr(n));
  61. x += h;
  62.  
  63. }
  64.  
  65.  
  66. }
  67. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement