Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program LR3;
- Uses
- System.SysUtils;
- Function ArrayRazmer () : Integer;
- Var
- N : Integer;
- Begin
- Writeln ('Размерность массива: ');
- Readln(N);
- ArrayRazmer := N;
- End;
- Type
- TMatrix = Array of Array of Integer;
- Function Massiv (N: Integer) : TMatrix;
- Var
- I,J : Integer;
- Arr : TMatrix;
- Begin
- SetLength (Arr, N, N);
- Writeln('Введите элементы матрицы: ');
- For I := 0 to N-1 do
- For J := 0 to N-1 do
- Readln(Arr[I,J]);
- Massiv := Arr;
- End;
- Function ZeroExist (N: Integer; Arr: TMatrix) : Boolean;
- Var
- DoesZeroExist : Boolean;
- I,J : Integer;
- Begin
- DoesZeroExist := False;
- For I := 0 to N-1 do
- For J := 0 to N-1 do
- If (Arr[I,J] = 0) then
- DoesZeroExist := True;
- ZeroExist := DoesZeroExist;
- End;
- Function SumTillZero ( DoesZeroExist : Boolean; Arr: TMatrix; N: integer) : Integer;
- Var
- Sum1 : Integer;
- I,J, ZeroI, ZeroJ : Integer;
- Istrue : Boolean;
- Begin
- If (DoesZeroExist = true) then
- Begin
- IsTrue := False;
- for I := 0 to N -1 do
- for J := 0 to N -1 do
- if ((Arr[I,J] = 0) and (IsTrue = False)) then
- Begin
- ZeroI := I;
- ZeroJ := J;
- IsTrue := True;
- End;
- End
- Else
- Writeln ('Нет нулей');
- Sum1 := 0;
- For I:= 0 To ZeroI Do
- For J:= 0 To ZeroJ Do
- Sum1:= Sum1 + Arr[I,J];
- Writeln ('Сумма до нуля: ', Sum1);
- SumtillZero := Sum1;
- End;
- Function Matrix (N:Integer; Arr: TMatrix) : Integer;
- Var
- I, j, Sum2 : integer;
- Begin
- Sum2 := 0;
- For I := 0 to N-1 do
- For J := 0 to N-1 do
- If ( I + J > N - 1) Then
- Sum2 := Sum2 + Arr[I,J];
- Writeln ('Под побочной диагональю: ', Sum2);
- Matrix := Sum2;
- End;
- Var
- Arr : TMatrix;
- N, Sum1, Sum2 : Integer;
- Zero : Boolean;
- Begin
- N := ArrayRazmer ();
- Arr := Massiv(N);
- Zero := ZeroExist(N,Arr);
- Sum1 := SumTillZero (Zero, Arr, N);
- Sum2 := Matrix (N, Arr);
- Readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement