- •1)Pascal
- •Int _tmain(int argc, _tchar* argv[])
- •2) Delphi
- •Interface
- •Implementation
- •Int _tmain(int argc, _tchar* argv[])
- •3)Delphi
- •Implementation
- •Int _tmain(int argc, _tchar* argv[])
- •Int _tmain(int argc, _tchar* argv[])
- •4B) Pascal
- •Interface
- •Implementation
- •4A)Pascal
- •Implementation
- •Int _tmain(int argc, _tchar* argv[])
- •5)Pascal
- •Implementation
- •Int _tmain(int argc, _tchar* argv[])
- •Int _tmain(int argc, _tchar* argv[])
- •6)Pascal
- •Interface
- •Implementation
- •7)Pascal
- •Interface
- •Implementation
3)Delphi
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var b,a,z:real; i,x:integer;
begin
i:=27; b:=1; a:=0;
i:=strtoint(Edit1.Text);
for x:=i to i+8 do
a:=a+cos(x*x*x)/2+cos(x*x)/3-8*sin(3*x+1);
for x:=i to i+5 do
b:=b*(sin(x*x)*cos(x*x*x)-sin(x)+5) ;
z:=a*a*a*b;
memo1.Lines.Add('a :'+floattostr(a));
memo1.Lines.Add('b :'+floattostr(b));
memo1.Lines.Add('z :'+floattostr(z)) ;
end;
end.
4а) С/С++
#include "stdafx.h"
#include "math.h"
Int _tmain(int argc, _tchar* argv[])
{
float y,e;
int k=1;
double a;
printf("Vvedite tochnist: ");
scanf("%f",&e);
y=0;
a=(2*sin(k+0.0)*sin(2*k-1+0.0)*cos(2*k+1+0.0)-6)/k;
do {
k=k+1;
a=(2*sin(k+0.0)*sin(2*k-1+0.0)*cos(2*k+1+0.0)-6)/k;
y=y+a;
}
while (abs(a)>e);
printf("\nKilkist elementiv: %i\n",k-1);
printf("\nSumma: %8.4f\n",y);
return 0;
}
\
4б) С/С++
#include "stdafx.h"
#include "math.h"
int fact(int n)
{
if (n<=1)
return 1;
else
return n*fact(n-1);
}
Int _tmain(int argc, _tchar* argv[])
{
float y,e,x;
int n,k=1;
double a;
printf("Vvedite tochnist: ");
scanf("%f",&e);
printf("Vvedite x (0:1): ");
scanf("%f",&x);
y=0;
a=pow((-1.0),k+0.0)*(2*sin(k+0.0)*sin(2*k-1+0.0)*cos(2*k+1+0.0)-6)/fact(k);
do
{
k=k+1;
a=pow((-1.0),k+0.0)*(2*sin(k+0.0)*sin(2*k-1+0.0)*cos(2*k+1+0.0)-6)/fact(k);
y=y+a;
}
while (abs(a)>e);
printf("\nKilkist elementiv: %i\n",k-1);
printf("\nSumma: %5.3f\n",y);
return 0;
}
4B) Pascal
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,facmod, StdCtrls,Math;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
// procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Code,Value:integer;
str1,str2:string;
x:real;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a,e,s:real;
k:integer;
begin
val(Edit1.Text,e,Code);
val(Edit2.Text,x,Code);
s:=0;
k:=1;
a:=power(-1,k)*(2*sin(x)*sin(2*x-1)*cos(1*x+1)-6)*power(x,k)/fact(k);
while abs(a)>e do
begin
k:=k+1;
a:=power(-1,k)*(2*sin(x)*sin(2*x-1)*cos(1*x+1)-6)*power(x,k)/fact(k);
s:=s+a;
end;
str(s:5:3,str1);
str(k-1,str2);
Memo1.Lines.Add('Сума='+str1);
Memo1.Lines.Add('Кількіть членів ряду='+str2);
end;
//procedure TForm1.Button2Click(Sender: TObject);
//Memo1.Clear;
//Edit1.Clear;
//end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Form1.Close;
end;
end.
4A)Pascal
var
Form1: TForm1;
Code,Value:integer;
str1,str2:string;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a,e,s:real;
k:integer;
begin
val(Edit1.Text,e,Code);
s:=0;
k:=1;
a:=(2*sin(k)*sin(2*k-1)*cos(2*k+1)-6)/k;
while abs(a)>e do
begin
k:=k+1;
a:=(2*sin(k)*sin(2*k-1)*cos(2*k+1)-6)/k;
s:=s+a;
end;
str(s:5:3,str1);
str(k-1,str2);
Memo1.Lines.Add('Сума='+str1);
Memo1.Lines.Add('Кількіть членів ряду='+str2);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Form1.Close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Clear;
Edit1.Clear;
end;
end.
5) С/С++
#include "stdafx.h"
#include "math.h"
#include <cmath>