:






 

:

Quot;

"

 

: : . . . . . 107226, 6  
, : . .

 

 

- 2007


4

 

: TStringGrid. .

: . k - (. . ).

 

:

unit Unit1;

 

interface

 

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Grids, Menus;

 

type

TForm1 = class(TForm)

StringGrid1: TStringGrid;

Edit1: TEdit;

Edit2: TEdit;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Button1: TButton;

Button2: TButton;

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

 

var

Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.Button1Click(Sender: TObject);

var n,m,i:integer;

ch:set of 'A'..'z';

i2,k:integer;

label L1; //Ìåòêà

begin

ch:=[];

//Âûïîëíåíèå çàäà÷è

for i:=1 To StrToInt(Edit1.Text) Do

for i2:=1 To StrToInt(Edit2.Text) Do

if StringGrid1.Cells[i,i2]='' Then //ïðîâåðÿåì íà íóëåâûå ïîëÿ

Begin

ShowMessage('Ìàññèâ ñîäåðæèò íóëåâûå ïîëÿ');

GoTo L1; //Ïåðåõîä ê ìåòêå

end;

for i:=1 To StrToInt(Edit1.Text) Do

for i2:=1 To StrToInt(Edit2.Text) Do

if not(StringGrid1.Cells[i,i2][1] in ch) then //åñëè íåò â ch òîãäà



begin

ch:=ch+[StringGrid1.Cells[i,i2][1]]; //Ïðîâåðÿåì ñèìâîë ñòðîêè ñ èíäåêñîì 1!

inc(k); //Óâåëè÷èâàåì ñ÷¸ò÷èê íà åäèíèöó (èíêðåìåíò)

end;

Label3.Caption:='Êîëè÷åñòâî íåïîâòîðÿþùèõñÿ ýëåìåíòîâ: '+IntToStr(k);

ch:=[];

k:=0;

L1:end; //Ìåòêà

 

procedure TForm1.FormCreate(Sender: TObject);

var n:integer;

begin

Edit1.Text:='3';

Edit2.Text:='3';

Button2Click(Sender);

end;

 

procedure TForm1.Button2Click(Sender: TObject);

var i:integer;

begin

for i:=1 To StrToInt(Edit1.Text) Do

StringGrid1.Cells[i,0]:=IntToStr(i);

for i:=1 To StrToInt(Edit2.Text) Do

StringGrid1.Cells[0,i]:=IntToStr(i);

StringGrid1.ColCount:=StrToInt(Edit1.Text)+1;

StringGrid1.RowCount:=StrToInt(Edit2.Text)+1;

StringGrid1.Cells[0,0]:='Ìàññèâ áóêâ';

 

end;

 

end.

:



 

 

: TStringGrid. .

 

<== | ==>
|

mylektsii.ru - - 2015-2018 . (0.013 .)