Created
October 13, 2012 14:06
-
-
Save vertrigo/3884726 to your computer and use it in GitHub Desktop.
бета версия :D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Program ex6; | |
| uses crt; | |
| type matr = array[1..4,1..4] of char; | |
| var a:matr; c:char; i,j:integer; s: set of 'a'..'z'; check:boolean; | |
| Begin | |
| clrscr; | |
| writeln('Введите символьную матрицу 4х4:'); | |
| i:=1; j:=1; | |
| repeat | |
| read(c); | |
| if (c <> chr(32)) and (c <> chr(10)) and (c <> chr(13)) then | |
| begin | |
| a[i,j]:=c; | |
| if (j > 4) then begin i:=i+1; j:=1; end; | |
| j:=j+1; | |
| end; | |
| until (i >= 4) and (j > 4); | |
| writeln('Исходная матрица:'); | |
| for i:=1 to 4 do begin | |
| for j:=1 to 4 do write(a[i,j]:3); | |
| writeln; | |
| end; | |
| s:=[]; | |
| check:=false; | |
| for i:=1 to 4 do | |
| for j:=1 to 4 do | |
| if (i=j) then s:=s+[a[i,j]]; | |
| for i:=1 to 4 do | |
| for j:=1 to 4 do | |
| if (j=4+1-i) and (a[i,j] in s) then | |
| check:=true; | |
| if check 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