Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Черкашин Практика 1-4.doc
Скачиваний:
1
Добавлен:
25.09.2019
Размер:
849.41 Кб
Скачать

Звіт №1

Завдання 1: ЛІНІЙНИЙ ОБЧИСЛЮВАЛЬНИЙ ПРОЦЕС

У відповідності з номером обчислити значення функції fn(x), де n – номер варіанту. Вираз для функції fn(x) визначити з таблиці 1. Вихідні дані (х) ввести з клавіатури довільні. Результати обчислень вивести на екран.

1)С/С++

#include "stdafx.h"

#include <cmath>

int _tmain(int argc, _TCHAR* argv[])

{float x,f=0;

printf("Vvedit x: ");scanf("%f",&x);

f=cos(2*x)*sin(fabs(x))/(15-5);

printf("Vidpovid : %5.2f\n",f);

return 0;

}

1)Pascal

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Button1: TButton;

Edit1: TEdit;

Label1: TLabel;

Label2: TLabel;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var x,f:real;

begin

x:=strtofloat(Edit1.Text);

f:=cos(2*x)*sin(abs(x))/(15-5);

Label1.caption:=('Vidpovid : '+floattostr(f))

end;

end.

2) C/C++

#include "stdafx.h"

#include <cmath>

Int _tmain(int argc, _tchar* argv[])

{float a,b,c,d,fi,sig,f,y,x;

printf("Vvedit x: ");

scanf("%d/n ",&x);

printf("Vvedit a: ");

scanf("%f/n ",&a);

printf("Vvedit b: ");

scanf("%f/n ",&b);

printf("Vvedit c: ");

scanf("%f/n ",&c);

printf("Vvedit d: ");

scanf("%f/n ",&d);

if (fabs(x)<10)

{f=tan(x+a)-log(fabs(b+7))/log(27.0);printf("F= %f",f);

y=fabs(sin((f*f)/5-2))+11*cos(6*f-1);}

else

{sig=c*pow(x*x+d*exp(1.3),1/5);printf("Sig= %f",sig);

y=13*cos(fabs(sig))*sin((sig*sig)-2);}

printf("\nVidpovid : %5.2f\n",y);

return 0;

}

2) Delphi

unit Unit1;

Interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Button1: TButton;

Edit1: TEdit;

Label2: TLabel;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

Edit5: TEdit;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Button2: TButton;

Button3: TButton;

Memo1: TMemo;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

Implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var x,a,b,c,d,f,y,sig:real;

begin

x:=strtofloat(Edit1.Text);

a:=strtofloat(Edit2.Text);

b:=strtofloat(Edit3.Text);

c:=strtofloat(Edit4.Text);

d:=strtofloat(Edit5.Text);

if (abs(x)<10) then

begin

f:=sin(x+a)/cos(x+a)-ln(abs(b+7))/ln(27.0);

y:=abs(sin((f*f)/5-2))+11*cos(6*f-1);

memo1.Lines.Add('1 vypadok ( |x|<10 )');

memo1.Lines.Add('F= ' +floattostr(f));

memo1.Lines.Add('y= ' +floattostr(y))

end

else

begin

sig:=c*exp(1/5*ln(x*x+d*exp(1.3)));

y:=13*cos(abs(sig)*sin(sig*sig-2));

memo1.Lines.Add('2 vypadok ( |x|<10 )');

memo1.Lines.Add('Sigma= ' +floattostr(sig));

memo1.Lines.Add('y= ' +floattostr(y));

end;

//.caption:=('Vidpovid : '+floattostr(y))

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

edit1.Clear;

edit2.Clear;

edit3.Clear;

edit4.Clear;

edit5.Clear;

memo1.Clear;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

close;

end;

end.

3)C/C++

#include "stdafx.h"

#include <cmath>

Int _tmain(int argc, _tchar* argv[])

{float a=0,b=1,Z,x; int i=27;

printf("Vvedit i : ");scanf("%d/n",&i);

for (x=i;x<=i+5;x++)

a=a+cos(x*x*x)/2+cos(x*x)/3-8*sin(3*x+1);

for (x=i;x<=i+8;x++)

b=b*(sin(x*x)*cos(x*x*x)-sin(x)+5);

printf("a= %5.2f\nb= %5.2f\n",a,b);

Z=a*a*a*b;

printf("Z= %5.2f\n",Z);

return 0;

}