Разработка приложений в системе Delphi. Шейкер Т.Д. - 81 стр.

UptoLike

Составители: 

procedure TForm1.Button7Click(Sender: TObject);
var xn,xk,hx,x,f:extended;
i,m:integer;
begin
try
case ComboBox1.ItemIndex of
0: begin
xn:=strtofloat(StringGrid2.Cells[1,1]);
xk:=strtofloat(StringGrid2.Cells[1,2]);
hx:=strtofloat(StringGrid2.Cells[1,3]);
end;
1: begin
xn:=strtofloat(StringGrid2.Cells[2,1]);
xk:=strtofloat(StringGrid2.Cells[2,2]);
hx:=strtofloat(StringGrid2.Cells[2,3]);
end;
2: begin
xn:=strtofloat(StringGrid2.Cells[3,1]);
xk:=strtofloat(StringGrid2.Cells[3,2]);
hx:=strtofloat(StringGrid2.Cells[3,3]) ;
end
else begin
xn:=0.1; xk:=1.2; hx:=0.1;
end;
end;
except
on EConvertError do
begin
ShowMessage('Ошибка преобразования числа');
exit;
end;
end;
m:=round((xk-xn)/hx)+1;
StringGrid1.RowCount:=m+1;
StringGrid1.Cells[1,0]:='x';
StringGrid1.Cells[2,0]:='f';
x:=xn;
for i:=1 to m do
begin
case ListBox1.ItemIndex of
0: f:=sin(x);
1: f:=cos(x);
2: f:=arctan(x-1)+2*x;
3: f:=exp(x*ln(1.5));
end;
StringGrid1.Cells[1,i]:=FloatToStrF(x,ffFixed,8,3);
StringGrid1.Cells[2,i]:=FloatToStrF(f,ffFixed,8,3);
x:=x+hx;
end;
end;
81
procedure TForm1.Button7Click(Sender: TObject);
var xn,xk,hx,x,f:extended;
    i,m:integer;
begin
 try
  case ComboBox1.ItemIndex of
  0: begin
      xn:=strtofloat(StringGrid2.Cells[1,1]);
      xk:=strtofloat(StringGrid2.Cells[1,2]);
      hx:=strtofloat(StringGrid2.Cells[1,3]);
     end;
  1: begin
      xn:=strtofloat(StringGrid2.Cells[2,1]);
      xk:=strtofloat(StringGrid2.Cells[2,2]);
      hx:=strtofloat(StringGrid2.Cells[2,3]);
     end;
  2: begin
      xn:=strtofloat(StringGrid2.Cells[3,1]);
      xk:=strtofloat(StringGrid2.Cells[3,2]);
      hx:=strtofloat(StringGrid2.Cells[3,3]) ;
     end
   else begin
           xn:=0.1; xk:=1.2; hx:=0.1;
          end;
   end;
  except
   on EConvertError do
    begin
      ShowMessage('Ошибка преобразования числа');
      exit;
    end;
 end;
 m:=round((xk-xn)/hx)+1;
 StringGrid1.RowCount:=m+1;
 StringGrid1.Cells[1,0]:='x';
 StringGrid1.Cells[2,0]:='f';
 x:=xn;
 for i:=1 to m do
  begin
   case ListBox1.ItemIndex of
     0: f:=sin(x);
     1: f:=cos(x);
     2: f:=arctan(x-1)+2*x;
     3: f:=exp(x*ln(1.5));
   end;
   StringGrid1.Cells[1,i]:=FloatToStrF(x,ffFixed,8,3);
   StringGrid1.Cells[2,i]:=FloatToStrF(f,ffFixed,8,3);
   x:=x+hx;
  end;
end;



                                81