{ (c) 2000 Matvey Ralchik }

include 'rtl.h'

const 
  items=8
  false=0
  true=1

int m[items]=10 20 50 40 30 60 70 80

proc print
int i
begin
  for i=0 to items-1
    putint(m[i])
    putchar(9)
  end
  putcrlf
end

proc sortup
int i t flag
begin
  flag=true
  while flag
    flag=false
    for i=0 to items-2
      if m[i]>m[i+1]
        flag=true
        t=m[i]
        m[i]=m[i+1]
        m[i+1]=t
      end
    end
  end
end

proc sortdown
int i t flag
begin
  flag=true
  while flag
    flag=false
    for i=0 to items-2
      if m[i]<m[i+1]
        flag=true
        t=m[i]
        m[i]=m[i+1]
        m[i+1]=t
      end
    end
  end
end

public proc main
  print
  sortup
  print
  sortdown
  print
end