Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program tp6_ej8;
- type
- mat = array [1..10,1..10] of integer;
- vec = array [1..10] of integer;
- procedure cargarVector (var vector:vec; n:byte);
- var
- i:byte;
- begin
- for i:=1 to n do
- readln(vector[i]);
- end;
- function xRy (x,y:integer):boolean;
- begin
- if (x-y>=3) then
- xRy:=true
- else
- xRy:=false;
- end;
- procedure generarMatrizBooleana (var matriz:mat;vector:vec;n:byte);
- var
- i,j:byte;
- begin
- for i:=1 to n do
- begin
- for j:=1 to n do
- if xRy(vector[i],vector[j]) then
- matriz[i,j]:=1
- else
- matriz[i,j]:=0;
- end;
- end;
- procedure mostrarmatriz (matriz:mat;n:byte);
- var
- i,j:byte;
- begin
- for i:=1 to n do
- begin
- for j:=1 to n do
- write(' ',matriz[i,j],' ');
- writeln();
- end;
- end;
- function reflexiva (matriz:mat;n:byte):boolean;
- var
- i,j:byte;
- begin
- for i:=1 to n do
- begin
- for j:=1 to n do
- if (i=j) then
- begin
- if (matriz[i,j]=1) then
- reflexiva:=true
- else
- reflexiva:=false;
- end;
- end;
- end;
- function simetrica (matriz:mat;n:byte):boolean;
- var
- i,j:byte;
- flag:boolean;
- begin
- flag:=false;
- for i:=1 to n do
- begin
- for j:=1 to n do
- if (matriz[i,j]=matriz[j,i]) then
- flag:=true
- else
- flag:=false;
- end;
- end;
- simetrica:=flag;
- var
- n,m:byte;
- vectorNum:vec;
- matrizRel:mat;
- begin
- writeln('cantidad de nros: ');
- readln(n);
- cargarVector(vectorNum,n);
- writeln('xRy sií x-y>=3');
- generarMatrizBooleana(matrizRel,vectorNum,n);
- mostrarmatriz(matrizRel,n);
- if simetrica(matrizRel,n) then
- writeln('R es simetrica y reflexiva')
- else
- begin
- if (reflexiva(matrizRel,n)) then
- writeln('R es reflexiva pero no simetrica')
- else
- writeln('R no es reflexiva ni simetrica');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement