Список идентификаторов, использованных в блок-схеме с кратким описанием:
§ Y, Z, Fact - идентификаторы типа real.
§ K – идентификатор типа Integer.
Текст к FORM 5
unit Unitcalc5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm5 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
.
.
Button39: TButton;
Label1: TLabel;
Label2: TLabel;
Bevel1: TBevel;
Bevel2: TBevel;
Bevel3: TBevel;
Bevel4: TBevel;
Bevel5: TBevel;
Bevel6: TBevel;
Bevel7: TBevel;
Bevel8: TBevel;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure Button1Click(Sender: TObject);
.
.
procedure Button39Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
s,s1,c:string;t,i,j:integer;
x,y,z,m,f:real;cf:char;
implementation
{$R *.dfm}
procedure operat(x,y:real;c:string;var z:real);
begin
if c='+' then z:=x+y;
if c='-' then z:=x-y;
if c='*' then z:=x*y;
if c='x^y' then z:=exp(y*ln(x));
if (c='/') then
if (y<>0) then z:=x/y else
messagedlg('На 0 делить нельзя',mterror,[mbok],0);
if c='' then z:=y;
end;
procedure okr(var c:string);
var i,j:integer;x:real;
begin
i:=length(c); j:=i;
while copy(c,j,1)='0' do
begin
delete(c,j,1);
j:=j-1;
end;
val(c,x,i);
if (x>1E+16) or (x<-1E+16) then
begin
s:=' 0';
messagedlg('Слишком большое чиссло',mtcustom,[mbok],0);
end;
end;
procedure o(p:string; var c,c1:string);
begin
if length(c)<16 then
begin
c:=c+p;c1:=c;
end;
end;
procedure TForm5.Button10Click(Sender: TObject);
begin
o('0',s,s1);
edit1.text:=(' '+s)
end;
procedure TForm5.Button1Click(Sender: TObject);
begin
o('1',s,s1);
edit1.text:=(' '+s)
end;
.
.
.
procedure TForm5.Button9Click(Sender: TObject);
begin
o('9',s,s1);
edit1.text:=(' '+s)
end;
procedure TForm5.Button20Click(Sender: TObject);
begin
if copy(s,1,1)='-'
then delete(s,1,1)
else s:='-'+s;
s1:=s;
edit1.text:=(' '+s)
end;
procedure TForm5.Button16Click(Sender: TObject);
begin
val(s1,y,i);
operat(x,y,c,z);
x:=z; c:='+';
str(z:6:6,s); okr(s);
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button21Click(Sender: TObject);
begin
val(s1,y,i);
operat(x,y,c,z);
x:=z; c:='-';
str(z:6:6,s);okr(s);
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button15Click(Sender: TObject);
begin
|
val(s1,y,i);
operat(x,y,c,z);
x:=z; c:='*';
str(z:6:6,s);okr(s);
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button14Click(Sender: TObject);
begin
val(s1,y,i);
operat(x,y,c,z);
x:=z; c:='/';
str(z:6:6,s); okr(s);
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button26Click(Sender: TObject);
begin
val(s1,y,i);
z:=y*y;
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button27Click(Sender: TObject);
begin
val(s1,y,i);
z:=y*y*y;
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button12Click(Sender: TObject);
begin
c:='';
t:=0;
s:='';
s1:=s;
y:=0;
edit1.text:=(' 0');
end;
procedure TForm5.Button30Click(Sender: TObject);
begin
val(s1,y,i);
z:=round(y);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button13Click(Sender: TObject);
begin
val(s1,y,i);
operat(x,y,c,z);
x:=z;
c:='';
str(z:6:6,s);
okr(s);
s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button19Click(Sender: TObject);
begin
val(s1,y,i);
if y<>0 then
begin
z:=1/y;
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
end else
begin
messagedlg('На 0 делить нельзя',mterror,[mbok],0);
{ edit1.text:=('E ');}
end;
s:='';t:=0;
end;
procedure TForm5.Button37Click(Sender: TObject);
begin
t:=0;
s:='';
s1:=s;
edit1.text:=(' 0');
end;
procedure TForm5.Button18Click(Sender: TObject);
begin
val(s1,y,i);
begin
if radiobutton1.Checked then
f:=y*3.14159265359/180
else f:=y; end;
z:=cos(f);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button22Click(Sender: TObject);
begin
val(s1,y,i);
begin
if radiobutton1.Checked then
f:=y*3.14159265359/180
else f:=y; end;
z:=sin(f);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button23Click(Sender: TObject);
begin
val(s1,y,i);
if y<>0
then begin
if radiobutton1.Checked
then
f:=y*3.14159265359/180
else f:=y;
z:=sin(f)/cos(f);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
end else
begin
messagedlg('На 0 делить нельзя',mterror,[mbok],0);
end;
s:='';t:=0;
end;
procedure TForm5.Button24Click(Sender: TObject);
begin
val(s1,y,i);
if y<>0
then begin
if radiobutton1.Checked
then
f:=y*3.14159265359/180
else f:=y;
z:=cos(f)/sin(f);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
end else
begin
messagedlg('На 0 делить нельзя',mterror,[mbok],0);
end;
s:='';t:=0;
end;
procedure TForm5.Button25Click(Sender: TObject);
|
begin
val(s1,y,i);
if y>=0 then begin
z:=sqrt(y);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
end else begin
messagedlg('Корень из отрицательного числа извлечь нельзя',mterror,[mbok],0);
end;
s:='';t:=0;
end;
procedure TForm5.Button28Click(Sender: TObject);
begin
val(s1,y,i);
operat(x,y,c,z);
x:=z;
c:='x^y';
str(z:6:6,s);okr(s);
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button32Click(Sender: TObject);
begin
z:=3.14159265359;
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button29Click(Sender: TObject);
begin
val(s1,y,i);
if y>=1 then begin
z:=ln(y);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
end else
begin
messagedlg('LN X<=0 неопределён',mterror,[mbok],0);
end;
s:='';t:=0;
end;
procedure TForm5.Button31Click(Sender: TObject);
var k:integer; fact:real;
begin
val(s1,y,i);
fact:=1;
k:=1;
if (y>1) and (y<=18) then
begin
y:=round(y);
repeat
k:=k+1;
fact:=fact*k;
until k=y;
end
else
begin
s:=' 0';
messagedlg('Слишком большое чиссло',mtcustom,[mbok],0);
end;
z:=round(fact);
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button38Click(Sender: TObject);
begin
val(s1,y,i); m:=m+y;
s:='';t:=0;
if m<>0 then edit2.text:=('M ')
else edit2.text:=(' ');
end;
procedure TForm5.Button39Click(Sender: TObject);
begin
val(s1,y,i); m:=m-y;
s:='';t:=0;
if m<>0 then edit2.text:=('M ')
else edit2.text:=(' ');
end;
procedure TForm5.Button34Click(Sender: TObject);
begin
val(s1,y,i); m:=y;
s:='';t:=0;
if m<>0 then edit2.text:=('M ')
else edit2.text:=(' ');
end;
procedure TForm5.Button35Click(Sender: TObject);
begin
str(m:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
procedure TForm5.Button36Click(Sender: TObject);
begin
m:=0;
if m<>0 then edit2.text:=('M ')
else edit2.text:=(' ');
end;
procedure TForm5.Button11Click(Sender: TObject);
begin
if t=0 then
begin
s:=s+'.'; s1:=s;
edit1.text:=(' '+s);
t:=1
end;
end;
procedure TForm5.RadioButton1Click(Sender: TObject);
begin
radiobutton1.checked:=true;
radiobutton2.checked:=false;
end;
procedure TForm5.RadioButton2Click(Sender: TObject);
begin
radiobutton2.checked:=true;
radiobutton1.checked:=false;
end;
procedure TForm5.Button17Click(Sender: TObject);
begin
val(s1,y,i);
z:=random;
str(z:6:6,s);okr(s);s1:=s;
edit1.text:=(' '+s);
s:='';t:=0;
end;
|
end.