Guest User

Untitled

a guest
May 20th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <vcl.h>
  2. #pragma hdrstop
  3. #include "math.h"
  4. #include "Unit1.h"
  5. #pragma package(smart_init)
  6. #pragma resource "*.dfm"
  7. TForm1 *Form1;
  8. //---------------------------------------------------------------------------
  9. __fastcall TForm1::TForm1(TComponent* Owner)
  10.         : TForm(Owner)
  11. {
  12. }
  13.  
  14. long double fact(int n)
  15. {
  16.    long double total = 1;
  17.         for(int i = 2; i < n; i++)
  18.         total *= i;
  19.         return total;
  20. }
  21.  
  22. void __fastcall TForm1::Button1Click(TObject *Sender)
  23. {
  24. try
  25. {
  26. float i;
  27. int n;
  28. float sum=0;
  29. float a=StrToFloat(Edit1->Text);
  30. float b=StrToFloat(Edit2->Text);
  31. float h=(b-a)/10;
  32.  
  33.         for(i=a;i<=b;)
  34.         {
  35.         Memo1->Lines->Add(FloatToStr((pow(i,exp)+pow(i,-(exp)))/2);
  36.         i=i+h;
  37.   sum=0;
  38. for(n=0;n<100;n++)
  39. {
  40. sum=sum+((pow(i,2*n))/(fact(2*n)));
  41. }
  42.  Memo2->Lines->Add(FloatToStr(sum));
  43. }
  44. }
  45. catch (...)
  46. {ShowMessage ("Not wrong");}
  47. }
  48. //---------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment