Skip to content

Instantly share code, notes, and snippets.

@vertrigo
Created October 13, 2012 11:20
Show Gist options
  • Select an option

  • Save vertrigo/3884200 to your computer and use it in GitHub Desktop.

Select an option

Save vertrigo/3884200 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,m,n:integer; dist:boolean;
Begin
clrscr;
writeln('Введите символьную матрицу 4х4:');
for i:=1 to 4 do
for j:=1 to 4 do read(a[i,j]);
writeln('Исходная матрица:');
for i:=1 to 4 do begin
for j:=1 to 4 do write(a[i,j]:3);
writeln;
end;
dist:=false;
for i:=1 to 4 do
for j:=1 to 4 do
begin
for n:=1 to 4 do
for m:=1 to 4 do begin
if (i=j) and (m=4+1-n) then
if (a[i,j] = a[n,m]) then dist:=true;
end;
end;
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