# Convert pascal to python

Discussion in 'Python' started by Ng Kok Wai, May 28, 2017.

1. ### Ng Kok Wai

Joined:
May 28, 2017
Messages:
1
0
Can someone help me to change this pascal to phyton script ?(Today need to submit ald, pls help!)

Code (Pascal):

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)

length : =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: Jun 1, 2017
Ng Kok Wai, May 28, 2017

2. ### John Joe

Joined:
Apr 25, 2017
Messages:
137
16
Location:
Malaysia
Hi Kok Wai, please wrap your code by using BB code editor.

John Joe, Jun 1, 2017
Ian likes this.

3. Joined:
Nov 13, 2005
Messages:
40