Upcoming SlideShare
×

# Tarea para el_aula.[1]

433 views

Published on

Published in: Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
433
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
3
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Tarea para el_aula.[1]

1. 1. Republica bolivariana de Venezuela Universidad Pedagógica experimental “Libertador”Instituto Pedagógico “Luis Beltrán Prieto Figueroa” Barquisimeto Estado-Lara<br /> Matriz Escalar Diagonal<br />Autores:<br />Pedro Prado<br />Nohemy Lugo<br />
2. 2. Matriz escalar.<br /> Una matriz escalar es una matriz diagonal en la que los elementos de la diagonal principal son iguales.<br />Ejemplo:<br />Elaborar un programa donde muestre un mensaje que identifique la matriz escalar.<br />
3. 3. Ejercicio de una Matriz Escalar Diagonal<br />unit Unit1;<br />interface<br />uses<br /> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br /> Dialogs, StdCtrls, Grids;<br />type<br /> TForm1 = class(TForm)<br /> StringGrid1: TStringGrid;<br /> Butcargar: TButton;<br /> Butsalir: TButton;<br /> Butmostrar: TButton;<br /> procedure ButcargarClick(Sender: TObject);<br /> procedure ButsalirClick(Sender: TObject);<br /> procedure ButmostrarClick(Sender: TObject);<br />
4. 4. private<br /> { Private declarations }<br /> public<br /> { Public declarations }<br /> end;<br />var<br /> Form1: TForm1;<br /> matriz: array [1..3,1..3] of integer;<br /> i,j:integer;<br /> columna,flia:array[1..3,1..3] of integer;<br />implementation<br />{\$R *.dfm}<br />Variables del ejercicio<br />
5. 5. Botón Cargar<br />procedure TForm1.ButcargarClick(Sender: TObject);<br />begin<br />for i:=1 to 3 do<br />for j:=1 to 3 do<br /> begin<br /> matriz[j,i]:= strtoint(inputbox('ingrese numero','numero',''));<br /> stringgrid1.Cells[j-1,i-1]:=inttostr(matriz[j,i]);<br /> end;<br /> end;<br />
6. 6. Botón mostrar <br />procedure TForm1.ButmostrarClick(Sender: TObject);<br />var<br />cont:integer;<br />cont2:integer;<br />begin<br />stringgrid1.Colcount:=3;<br />stringgrid1.RowCount:=3;<br />i:=0;<br />j:=0;<br />cont:=0;<br />cont2:=0;<br />for i:=1 to 3 do<br />for j:=1 to 3 do<br />begin<br />if ((matriz[i,i])<>0) then<br />begin<br />cont:=cont+1;<br />end;<br />
7. 7. if (i<>j) and (matriz[i,j]=0) and (matriz[j,i]=0) then<br />begin<br />cont2:=cont2+1;<br />//stringgrid1.cells[j-i,i-j]:= inttostr(matriz[i,j]);<br />end;<br />end;<br />if (cont2=6) and (cont=9) then<br />begin<br />showmessage ('la matriz escalar diagonal');<br />end;<br />if (cont <9) then<br />begin<br />showmessage('la matriz no es escalar diagonal');<br />end<br />else<br />if (cont2 <> 6) then<br />begin<br />showmessage ('la matriz no es escalar diagonal');<br />end;<br />end;<br />end.<br />
8. 8. Formulario del Programa<br />Botón Procedure Salir<br />Botón del Procedure Cargar<br />Botón Procedure Mostrar.<br />StringGrid<br />