Presentación de matrices

8

Transcript of Presentación de matrices

Page 1: Presentación de matrices
Page 2: Presentación de matrices

unit Unit1;Interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids;type TForm1 = class(TForm) Caja_Dimension: TEdit; Label2: TLabel; Label3: TLabel; Rejilla: TStringGrid; Boton_Llenar: TButton; Boton_Validar: TButton; Boton_Salir: TButton; Label4: TLabel; Eti_Resultado: TLabel; procedure Boton_SalirClick(Sender: TObject); procedure Boton_LlenarClick(Sender: TObject); procedure Boton_ValidarClick(Sender: TObject); private { Private declarations } public { Public declarations } end;

Page 3: Presentación de matrices

type Arreglo_Matriz = Array [1..10,1..10] of real;var Form1: TForm1; Matriz_A: Arreglo_Matriz;

implementation

{$R *.dfm}

Page 4: Presentación de matrices

Procedure Llenar_Matriz (out Arreglo:Arreglo_Matriz; Cont:Integer); var fila,columna:integer; begin for fila:=1 to Cont do for columna:=1 to Cont do Arreglo[fila,columna]:=StrtoFloat(inputbox('Llenando Arreglo','Intro elemento ['+inttostr(fila)+','+inttostr(columna)+']','')); end;

Page 5: Presentación de matrices

procedure Cargar_Rejilla ( Arreglo:Arreglo_Matriz; Cont:Integer; Rejilla:TStringGrid); var fila,Columna:integer; begin

for fila:=1 to Cont do for columna:=1 to Cont do begin Rejilla.Cells[columna-1,fila-1]:=FloatToStr(Arreglo[fila,columna]); end; end;

Page 6: Presentación de matrices

procedure TForm1.Boton_LlenarClick(Sender: TObject); var Cantidad:integer; begin Cantidad:=StrToInt(Caja_Dimension.text); Llenar_Matriz(Matriz_A,Cantidad); Rejilla.RowCount:=StrtoInt(Caja_Dimension.Text); Rejilla.ColCount:=StrtoInt(Caja_Dimension.Text); Cargar_Rejilla(Matriz_A,Cantidad,Rejilla); end;

Page 7: Presentación de matrices

procedure TForm1.Boton_ValidarClick(Sender: TObject);var Cantidad,fila,columna:integer; Valida:boolean; begin Valida:=true; Cantidad:=StrToInt(Caja_Dimension.text); for fila:=1 to Cantidad do for columna:=1 to Cantidad do begin If (fila <> columna) and (Matriz_A[fila,columna] <> 0) then Valida:=false; end; If (Valida = true) then Eti_Resultado.Caption:= 'Esta es una Matriz DIAGONAL' else Eti_Resultado.Caption:= 'NO es una Matriz DIAGONAL'; end;

Page 8: Presentación de matrices

procedure TForm1.Boton_SalirClick(Sender: TObject);Begin Showmessage (‘El programa a finalizado’); Close; end;end.