Created
November 19, 2012 17:25
-
-
Save vertrigo/4112063 to your computer and use it in GitHub Desktop.
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 rgr5; | |
| uses crt; | |
| const n = 4; | |
| type matr = array[1..n,1..n] of real; | |
| var w:matr; | |
| procedure obr(var a:matr; n:integer); | |
| var i,j:integer; | |
| begin | |
| for i:=1 to n do | |
| for j:=1 to n do begin | |
| if (i < j) then a[i,j]:=sqr(i)+j; | |
| if (i = j) then a[i,j]:=0.5; | |
| if (i > j) then a[i,j]:=i+sqr(j); | |
| end; | |
| end; | |
| procedure vivod(a:matr; m_name:char; n:integer); | |
| var i,j:integer; | |
| begin | |
| writeln('Исходная матрица ',m_name,':'); | |
| for i:=1 to n do begin | |
| for j:=1 to n do write(a[i,j]:5:1); | |
| writeln; | |
| writeln; | |
| end; | |
| end; | |
| procedure result(a:matr; n:integer); | |
| var min,max:real; i,j,minj,maxj,mini,maxi:integer; | |
| begin | |
| max:=-maxint; min:=maxint; | |
| for i:=1 to n do begin | |
| for j:=1 to n do begin | |
| if (a[i,j] <= min) then begin | |
| min:=a[i,j]; | |
| mini:=i; | |
| minj:=j; | |
| end; | |
| if (a[i,j] >= max) then begin | |
| max:=a[i,j]; | |
| maxi:=i; | |
| maxj:=j; | |
| end; | |
| end; | |
| end; | |
| writeln('Минимальный элемент находится на пересечении следующей строки:'); | |
| for j:=1 to n do begin | |
| write(a[mini,j]:5:1); | |
| end; | |
| writeln; | |
| writeln('и столбца матрицы:'); | |
| writeln; | |
| for i:=1 to n do begin | |
| writeln(a[i,minj]:5:1); | |
| writeln; | |
| end; | |
| writeln('Максимальный элемент находится на пересечении следующей строки:'); | |
| for j:=1 to n do begin | |
| write(a[maxi,j]:5:1); | |
| end; | |
| writeln; | |
| writeln('и столбца матрицы:'); | |
| writeln; | |
| for i:=1 to n do begin | |
| writeln(a[i,maxj]:5:1); | |
| writeln; | |
| end; | |
| end; | |
| Begin | |
| clrscr; | |
| obr(w,n); | |
| vivod(w,'W',n); | |
| writeln('Нажмите любую клавишу для продолжения...'); | |
| readkey; | |
| result(w,n); | |
| readkey; | |
| End. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment