Skip to content

Instantly share code, notes, and snippets.

@residentkrm
Created July 17, 2013 16:20
Show Gist options
  • Save residentkrm/6022103 to your computer and use it in GitHub Desktop.
Save residentkrm/6022103 to your computer and use it in GitHub Desktop.
Program ex6;
uses crt;
type matr = array[1..4,1..4] of char;
var a:matr; i,j:integer; dist:boolean; gdiag: set of char;
Begin
clrscr;
writeln('Введите символьную матрицу 4х4:');
for i:=1 to 4 do
for j:=1 to 4 do read(a[i,j]);
readln;
writeln('Исходная матрица:');
for i:=1 to 4 do begin
for j:=1 to 4 do write(a[i,j]:3);
writeln;
end;
for i:=1 to 4 do
for j:=1 to 4 do
if i=j
then
gdiag:=gdiag+[a[i,j]];
for i:=1 to 4 do
for j:=1 to 4 do
if j=4+1-i
then
if a[i,j] in gdiag then dist:=true;
if dist then begin
writeln('Элементы побочной диагонали: ');
for i:=1 to 4 do
for j:=1 to 4 do
if (j=4+1-i) then write(a[i,j]:3);
end else begin
writeln('Элементы главной диагонали: ');
for i:=1 to 4 do
for j:=1 to 4 do
if (i=j) then write(a[i,j]:3);
end;
Readkey;
End.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment