Использовался C++Builder 2006
Код: Выделить всё
//---------------------------------------------------------------------------
#include <vcl.h>
#include <math.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
double b[]={1./6, 1./30, 1./42, 1./30, 5./66, 691./2730, 7./6, 3617./510,
43867./798, 174611./330, 854513./138}; //массив чисел Бернулли
int fact(int n);
double step(double w, int n);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1->Clear();
Edit2->Clear();
Edit3->Clear();
Edit3->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
if(!((Key>= '0' && Key <= '9') || Key == VK_BACK || Key == ',' || Key == '-'))
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
{
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &Key)
{
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit4KeyPress(TObject *Sender, char &Key)
{
Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double razn,x,y,t,s, r;
int k,l;
int a[]={1,3,5,7,9,11,13,15,17,19,21};
x=StrToFloat(Edit1->Text);
if((x<=-1)||(x==0)||(x>=1))
{
ShowMessage("Неверное значение x");
return;
}
else
{
y=1./sin(x); //расчет по формуле
Edit3->Text=FloatToStr(y);
for(k=0;k<11;k++)
{
double z=2*(step(2,(a[k]-1))-1);
s=step(r,a[k]);
l=fact(a[k]);
x=x+(z*(b[k]*s)/l);//расчет по формуле суммы ряда
}
razn=y-x;
Edit2->Text=FloatToStr(x);
Edit4->Text=FloatToStr(razn);
}
//---------------------------------------------------------------------------
int fact(int n)
{
int q=1;
for(int i=1;i<=n;i++)
q=q*i;
return q;
}
double step(double w, int n)
{
double p=1.;
for(int j=1;j<=n;j++)
p=p*w;
return p;
}
[C++ Error] Unit1.cpp(85): E2141 Declaration syntax error - указывая на 85 строку,
[C++ Error] Unit1.cpp(102): E2139 Declaration missing ; - указывая на 102 строку,
[C++ Error] Unit1.cpp(102): E2134 Compound statement missing } - указывая на 103 строку.