Построение блок схем алгоритмов. Алгоритмические языки высокого уровня
#include<iostream.h>
#include<math.h>
void main()
{
float dx=0.25,y,x;
for (x=2.0;x<=5.0 +0.5*dx;x+=dx)
{
if (x<=3.5)
y=cos(x)*cos(x);
else
y=sin(x)*log(x);
cout<<"Y= "<<y<<endl;
}
}
Program lab_2;
Uses Crt;
Const
dx=0.25;
Var
x,y:real;
Begin
clrscr;
x:=2.0;
while x<5.0+dx/2 do
begin
if x<=3.5 then
begin
y:=sqr(cos(x));
end
else y:=sin(x)*ln(x);
writeln(y:3:5);
x:=x+dx;
end;
readln;
End.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Const
dx=0.25;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button2Click(Sender: TObject);
begin
Close();
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Code:integer;
x,y:real;
s:string[11];
begin
x:=2.0;
while (x<5.0+0.5*dx) do
begin
if x<=3.5 then y:=sqr(cos(x))
else y:=sin(x)*ln(x);
x:=x+dx;
Str(y:2:7,s);
Listbox1.Items.Add(s);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Listbox1.Items.Clear;
end;
end.