Добавил:
rn Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
13
Добавлен:
14.12.2017
Размер:
3 Кб
Скачать
unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Grids, Vcl.StdCtrls,
  Vcl.Buttons;

type
  TForm2 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    SGItog: TStringGrid;
    SGIshod: TStringGrid;
    LSort: TLabel;
    ESort: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormActivate(Sender: TObject);
var
temp, I, J, K : integer;
MIs, MIt, Msh : array [1..5,1..5] of integer;
Mass : array [1..25] of integer;
begin
randomize;
  for I := 1 to 5 do
    begin
    SGIshod.Cells[0,I] := IntToStr(I);
	  SGIshod.Cells[I,0] := IntToStr(I);
    SGItog.Cells[0,I] := IntToStr(I);
    SGItog.Cells[I,0] := IntToStr(I);
    end;
 For I := 1 to 5 do
	For J := 1 to 5 do
		begin
			MSh[I,J] := 0;
			MIt[I,J] := 0;
		end;

  For J := 1 to 5 do
		For I := 1 to J-1 do
			MSh[I,J] := 1;

  For I := 1 to 5 do
		For J := 1 to 5 do
		  begin
				MIs[I,J] := Random(9)+1;
				SGIshod.Cells[I,J] := IntToStr(MIs[I,J]);
			end;

  For I := 1 to 5 do
		For J := 1 to 5 do
	  	begin
				If MSh[I,J] = 1 then MIt[I,J] := MIs[I,J];
				SGItog.Cells[I,J] := IntToStr(MIt[I,J]);
		  end;
  k := 0;
  For I := 1 to 5 do
	  For J := 1 to 5 do
	    begin
		    Inc(k);
		    Mass[k] := MIs[J,I];
	    end;


  LSort.Caption := '';
For I:=1 to 25 do LSort.Caption := LSort.Caption+IntToStr(Mass[I])+ '';
  for I := 1 to 25 do
 begin
  j:=i;
  temp:=Mass[i];
  while ((j>1)and (Mass[j-1]>temp)) do
    begin
    Mass[j] := Mass[j-1];
    dec(j);
    end;
  Mass[j]:=temp;
 end;

 k:=0;
 ESort.Caption:='';

   for I := 1 to 25 do
     ESort.Caption := ESort.Caption+IntToStr(Mass[I])+ ' ';
end;
end.
Соседние файлы в папке Массивы (лаба)
  • #
    14.12.2017763 б12Project1.dproj.local
  • #
    14.12.2017183 б12Project1.identcache
  • #
    14.12.201759 Кб13Project1.res
  • #
    14.12.2017171 б12Project1.stat
  • #
    14.12.20176 Кб12Unit2.dfm
  • #
    14.12.20173 Кб13Unit2.pas