You are on page 1of 2

unit Unit1;

interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, Grids, StdCtrls, Menus;
type
matriz= array[1..4 , 1..4] of integer;
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
StringGrid2: TStringGrid;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Label1: TLabel;
Button11: TButton;
Button12: TButton;
Button13: TButton;
StringGrid3: TStringGrid;
Button14: TButton;
Button15: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button16: TButton;
Label5: TLabel;
Label6: TLabel;
Button17: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Salir1Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure Button17Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
mat : matriz;
i:integer;
j:integer;
carga: integer;
mat2:matriz;
mata:matriz;
matb:matriz;
resultado:matriz;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
i:= 0;
j:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
mat[j,i]:= strtoint(inputbox('Ingrese un Numero','','0'));
stringgrid1.Cells[j -1 , i -1]:= inttostr(mat[j,i]);
carga:= mat[j,i];
end;

button2.Enabled := true;
button3.Enabled := true;
button4.Enabled := true;
button5.Enabled := true;
button6.Enabled := true;
button7.Enabled := true;
button8.Enabled := true;
button9.Enabled := true;
button10.Enabled := true;
button11.Enabled := true;
button12.Enabled := true;
button13.Enabled := true;
button14.Enabled := true;
button15.Enabled := true;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
fila:integer;
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 1;
fila:= strtoint(inputbox('Ingrese una Fila','','0'));
for i:= 1 to 4 do
for j:= 1 to 4 do
begin

stringgrid3.Cells[j-1 , 1-1]:= inttostr(mat[j,fila]);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
columna:integer;
begin
stringgrid3.ColCount:= 1;
stringgrid3.RowCount:= 4;
columna:= strtoint(inputbox('Ingrese una Columna','','0'));
for i:= 1 to 4 do
for j:= 1 to 4 do
begin

stringgrid3.Cells[1-1 , i-1]:= inttostr(mat[columna,i]);
end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
stringgrid3.Cells[i-1,j-1]:= inttostr(mat[j,i]);
end;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
i:= 0;
j:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin

stringgrid3.Cells[j-1,i-1]:= inttostr(-mat[j,i]);
end;
end;

procedure TForm1.Button6Click(Sender: TObject);
var
suma:integer;
begin
i:= 0;
j:= 0;
suma:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
suma:= suma + mat[j,i];
end;
if suma = 0 then
begin
showmessage('Es Nula');
end
else
begin
showmessage('No Es Nula');
end;
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
i:= 0;
j:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
stringgrid3.Cells[j-1 , i-1]:= ' ';
end;
stringgrid3.Cells[0,0]:= inttostr(mat[1,1]);
stringgrid3.Cells[1,1]:= inttostr(mat[2,2]);
stringgrid3.Cells[2,2]:= inttostr(mat[3,3]);
stringgrid3.Cells[3,3]:= inttostr(mat[4,4]);
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
i:= 0;
j:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
stringgrid3.Cells[j-1 , i-1]:= ' ';
end;
stringgrid3.Cells[3,0]:= inttostr(mat[4,1]);
stringgrid3.Cells[2,1]:= inttostr(mat[3,2]);
stringgrid3.Cells[1,2]:= inttostr(mat[2,3]);
stringgrid3.Cells[0,3]:= inttostr(mat[1,4]);
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
if mat[2,1] = mat[1,2]then
begin
if mat[3,1] = mat[1,3] then
begin
if mat[4,1] = mat[1,4] then
begin
if mat[4,2] = mat[2,4] then
begin
if mat[4,3] = mat[3,4] then
begin
if mat[3,2] = mat[2,3] then
begin
Showmessage('La Matriz es Simetrica');
end
else
begin
Showmessage('La Matriz es No Simetrica');
end;
end;
end;
end;
end;

end
else
begin
Showmessage('La Matriz es No Simetrica');
end;

end;

procedure TForm1.Button10Click(Sender: TObject);
var
cont:integer;
cont2:integer;
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
i:= 0;
j:= 0;
cont:= 0;
cont2:= 0;
for i:=1 to 4 do
for j:= 1 to 4 do
begin
if ((mat[i,i])<> 0 ) then
begin
cont:= cont + 1;
end;
if (i <> j) and (mat[i,j]=0) and (mat[j,i]=0) then
begin
cont2:= cont2 + 1;
//stringgrid2.Cells[j-1,i-1]:= inttostr(mat[i,j]);
end;
end;

if (cont2 = 12) and (cont= 16) then
begin
Showmessage('La Matriz es Diagonal');
end;
if (cont < 16 ) then
begin
Showmessage('La Matriz no es Diagonal');
end
else
if (cont2 <> 12 ) then
begin
Showmessage('La Matriz no es Diagonal');
end;
end;

procedure TForm1.Button11Click(Sender: TObject);
var
cont:integer;
cont2:integer;
begin
i:= 0;
j:= 0;
cont:= 0;
cont2:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
if ((mat[i,i]) = (mat[j,j])) then
begin
cont:= cont + 1;
end;
if (mat[i,i]) = 0 then
begin
cont2:= cont2 + 1;
end;
if (i<>j) and (mat[i,j]=0) and (mat[j,i]=0) then
begin
cont2:= cont2 +1 ;
end;
end;
if (cont2 = 12) and (cont = 16) then
begin
Showmessage('La matriz es Escalar');
end;
if (cont < 16) then
begin
Showmessage('La Matriz No es Escalar');
end
else
if (cont2<>12) then
begin
Showmessage('La Matriz No es Escalar');
end;
end;

procedure TForm1.Button12Click(Sender: TObject);
var
cont:integer;
cont2:integer;
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
i:= 0;
j:= 0;
cont:= 0;
cont2:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
if (mat[i,i]) = 1 then
begin
cont:= cont + 1;
end;
if (i<>j) and (mat[i,j]=0) and (mat[j,i]=0) then
begin
cont2:= cont2 +1 ;
end;
end;
if (cont2 = 12) and (cont = 16) then
begin
Showmessage('La matriz es Identidad');
end;
if (cont < 16) then
begin
Showmessage('La Matriz No es Identidad');
end
else
if (cont2<>12) then
begin
Showmessage('La Matriz No es Identidad');
end;
end;

procedure TForm1.Button13Click(Sender: TObject);
var
pro:integer;
begin
label5.Visible := true;
label6.Visible := true;
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
pro:=0;
i:=0;
j:=0;
pro:= strtoint(inputbox('Ingrese un Numero','','0'));
label6.Caption := inttostr(pro);
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
mat2[j,i]:= (pro * mat[j,i]);
stringgrid3.Cells[j-1,i-1]:= inttostr(mat2[j,i]);
end;
end;

procedure TForm1.Button14Click(Sender: TObject);
var
suma:integer;
mb:integer;
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;

for i:= 1 to 4 do
for j:= 1 to 4do
begin
mb:= strtoint(inputbox('Ingrese La Matriz a sumar','','0'));
stringgrid2.Cells[j-1,i-1]:= inttostr (mb);
matb[j,i]:= mb;
end;

for i:= 1 to 4 do
for j:= 1 to 4do
begin
suma:= mat[j,i] + matb[j,i];
resultado[i,j]:= suma;
stringgrid3.Cells[j-1,i-1]:= inttostr(suma);
end;

end;

procedure TForm1.Button15Click(Sender: TObject);
var
conta:integer;
contb:integer;
begin
stringgrid3.ColCount:= 4;
stringgrid3.RowCount:= 4;
conta:= 0;
contb:=0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
resultado[i,j]:=0;
//stringgrid3.Cells[j-1,i-1]:= inttostr(resultado[i,j]);
end;

for i:= 1 to 3 do
for j:= 2 to 4 do
begin
if (i<>j) and ((mat[i,j]) = 0 )then
begin
conta:= conta + 1;
resultado[i,j]:= mat[i,j];
//stringgrid3.Cells[j-1,i-1]:= inttostr(resultado[i,j]);
end;
if (i<>j) and ((mat[j,i]) = 0) then
begin
contb:= contb + 1;
resultado[i,j]:= mat[i,j];
//stringgrid3.Cells[j-1,i-1]:= inttostr(resultado[i,j]);
end;
end;

if (conta = 6) then
begin
showmessage('La parte inferior');
end
else
if (contb = 6) then
begin
showmessage('La parte superior');
end
else
if (conta <> 6) and (contb <> 6) then
begin
showmessage('La Matriz no es Diagonal');
end;

end;


procedure TForm1.Button16Click(Sender: TObject);
begin
close
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
button2.Enabled := false;
button3.Enabled := false;
button4.Enabled := false;
button5.Enabled := false;
button6.Enabled := false;
button7.Enabled := false;
button8.Enabled := false;
button9.Enabled := false;
button10.Enabled := false;
button11.Enabled := false;
button12.Enabled := false;
button13.Enabled := false;
button14.Enabled := false;
button15.Enabled := false;
label5.Visible := false;
label6.Visible := false;
end;

procedure TForm1.Salir1Click(Sender: TObject);
begin
close
end;

procedure TForm1.N1Click(Sender: TObject);
begin
i:= 0;
j:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
mat[j,i]:= strtoint(inputbox('Ingrese un Numero','','0'));
stringgrid1.Cells[j -1 , i -1]:= inttostr(mat[j,i]);
carga:= mat[j,i];
end;

button2.Enabled := true;
button3.Enabled := true;
button4.Enabled := true;
button5.Enabled := true;
button6.Enabled := true;
button7.Enabled := true;
button8.Enabled := true;
button9.Enabled := true;
button10.Enabled := true;
button11.Enabled := true;
button12.Enabled := true;
button13.Enabled := true;
button14.Enabled := true;
button15.Enabled := true;

end;

procedure TForm1.Button17Click(Sender: TObject);
begin
button2.Enabled := false;
button3.Enabled := false;
button4.Enabled := false;
button5.Enabled := false;
button6.Enabled := false;
button7.Enabled := false;
button8.Enabled := false;
button9.Enabled := false;
button10.Enabled := false;
button11.Enabled := false;
button12.Enabled := false;
button13.Enabled := false;
button14.Enabled := false;
button15.Enabled := false;
label5.Visible := false;
label6.Visible := false;
i:= 0;
j:= 0;
for i:= 1 to 4 do
for j:= 1 to 4 do
begin
mat[j,i]:= strtoint('0') ;
stringgrid1.Cells[j -1 , i -1]:= inttostr(mat[j,i]);
stringgrid2.Cells[j -1 , i -1]:= inttostr(mat[j,i]);
stringgrid3.Cells[j -1 , i -1]:= inttostr(mat[j,i]);
carga:= mat[j,i];
end;
end;

end.

You might also like