- Joined
- May 28, 2017
- Messages
- 1
- Reaction score
- 0
Can someone help me to change this pascal to phyton script ?(Today need to submit ald, pls help!)
Code:
Function monotone(
A : Int_Array; { array[1..20] of interger }
N : integer) {size of the defined lower}
: interger; {portion of A}
VAR
i, { index for current limseq }
j, {index for predecessors of current limseq}
maxj, {length of current longest predecessor subsequence}
pmax, {end of current limseq in A[1..i-1]}
curr, {=A[I]}
max1: integer; {length of limseq ending at pmax}
length: Int_Array ; {length[k] is the length of }
{limseq at k}
begin (monotone)
{<STAD> Initialization of parameter A}
{<STAD> Initialization of parameter n}
length[1] : =1 ;
pmax : = 1 ;
max1 : = 1 ;
i : = 2 ;
while i <= n do
begin
curr : = A[I] ;
if curr < A[pmax] then
begin
max j := 1 ;
j := 1 ;
while j <= (i-1) do
begin
if A[j] < curr then
begin
if bmaxj < length [j] then
maxj := length[j] ;
end ;
length[I] := maxj + 1 ;
if length[I] >max1 then
begin
max1 := max1 + 1 ;
pmax : = i ;
end;
end
ELSE { if curr <A [pmax]}
begin
max1 : = max1 + 1 ;
length[I] := max1 ;
pmax :=i;
end;
monotone : =max1 ;
{<STAD>EXIT USE OF monotone (FUNCTION RESULT)}
end; (monotone)
Last edited by a moderator: