2014 dxdy logo

Научный форум dxdy

Математика, Физика, Computer Science, Machine Learning, LaTeX, Механика и Техника, Химия,
Биология и Медицина, Экономика и Финансовая Математика, Гуманитарные науки




 
 помогите разобратса задачка по Delphi7
Сообщение11.01.2010, 16:59 
немагу найти ошыбку вроде чета нето с типами даных...
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;

type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var q,w:array[1..5,1..5] of real;
sum,dp,dd,d_12,sp,s_12,r,sd:real;
i,j:integer;
begin
begin
sum:=0;
for i:=1 to 5 do
begin
for j:=1 to 4 do
begin
q[i,j]:=StrToFloat(StringGrid1.Cells[i-1,j-1]);
sum:=sum+q[i,j];
end;
end;
edit1.text:=(floattostr(sum));
if sum<0 then
begin
for i:=1 to 5 do
begin
for j:=1 to 5 do
begin
w[i,j]:=abs(q[i,j]);
end;
end;
end;
if sum>0 then
begin
for i:=1 to 5 do
begin
for j:=1 to 5 do
w[i,j]:=q[i,j]*(-1);
end;
end;
stringgrid2.cells[i-1,j-1]:=floattostr(w[i,j]);
begin
for i:=1 to 5 do
begin
sp:=sp+q[i,1];
sd:=sd+q[i,2];
end;
end;
s_12:=sp+sd;
edit3.text:=(floattostr(s_12));
for j:=1 to 5 do
begin
dp:=dp*q[1,j];
dd:=dd*q[2,j];
end;
d_12:=dp*dd;
edit2.text:=(floattostr(d_12));

begin
if d_12<s_12 then r:=exp((1/3)*ln(d_12))
else r:=exp((1/3)*ln(s_12));
end;
edit4.Text:=(floattostr(r));

end;
end;
end.

 
 
 
 Re: помогите разобратса задачка по Delphi7
Сообщение11.01.2010, 19:16 
Аватара пользователя
Цитата:
...
procedure TForm1.Button1Click(Sender: TObject);
var q,w:array[1..5,1..5] of real;
sum,dp,dd,d_12,sp,s_12,r,sd:real;
i,j:integer;
begin
begin

sum:=0;
...
Вот это в глаза бросилось.

А зачем столько ненужных begin-end`ов?
Вот тут, например:
Используется синтаксис Pascal
edit2.text:=(floattostr(d_12));
  begin
    if d_12<s_12 then r:=exp((1/3)*ln(d_12))
    else r:=exp((1/3)*ln(s_12));
  end;
edit4.Text:=(floattostr(r));

 
 
 [ Сообщений: 2 ] 


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group