Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vcl.h>
- #pragma hdrstop
- #include "math.h"
- #include "Unit1.h"
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- long double fact(int n)
- {
- long double total = 1;
- for(int i = 2; i < n; i++)
- total *= i;
- return total;
- }
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- try
- {
- float i;
- int n;
- float sum=0;
- float a=StrToFloat(Edit1->Text);
- float b=StrToFloat(Edit2->Text);
- float h=(b-a)/10;
- for(i=a;i<=b;)
- {
- Memo1->Lines->Add(FloatToStr((pow(i,exp)+pow(i,-(exp)))/2);
- i=i+h;
- sum=0;
- for(n=0;n<100;n++)
- {
- sum=sum+((pow(i,2*n))/(fact(2*n)));
- }
- Memo2->Lines->Add(FloatToStr(sum));
- }
- }
- catch (...)
- {ShowMessage ("Not wrong");}
- }
- //---------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment