
27.02.2009, 02:11
|
 |
Прохожий
|
|
Регистрация: 22.02.2009
Сообщения: 14
Репутация: 10
|
|
Здравствуйте. В 1 варианте я начудил. Вроде бы переделал, сейчас проблема в вводе знач. в массив. Програм. ругается " Access violation at accress 004601c8 in module ' Project. exe' Write of address 00000008", в англ "0".
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
//Label1: TLabel;
// Label2: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Type Mass = array of real;
Mass1 = array of real;
var
Form1: TForm1;
a: Mass;
b: Mass1;
n: Longint;
implementation
{$R *.dfm}
function nalichie (a, b:array of real; n: Longint): boolean;
var
i: integer;
begin
result:= true;
i:= 1;
repeat
if a[i] = b[i] then
Result:= False
else
i:= i+1;
until (i>n) or (Result=False);
if Result then
ShowMessage ('нет равных элементов' )
else
ShowMessage ( 'есть равные элементы ');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
n:= StrToInt (Trim (Edit1.Text));
SetLength(a,n);
StringGrid1.RowCount:= 1;
StringGrid1.ColCount:=n;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
n:= StrToInt (Trim (Edit2.Text));
SetLength(a,n);
StringGrid2.RowCount:= 1;
StringGrid2.ColCount:=n;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i: Longint;
begin
for i:= 1 to n do
a[i]:= StrToInt (StringGrid1.Cells [ i-1, 0]);
for i:= 1 to n do
b[i]:= StrToInt (StringGrid2.Cells [ i-1, 0]);
nalichie (a,b,n)
end;
end.
|