写一个通用方法用于判定给定的数组是否已排好序
Algorithm compare(a,n)
Begin
j=1;
while
(j<n and a[j]<=a[j+1])
do j=j+1
If j=n
then
return true
Else
while
(j<n and a[j]>=a[j+1])
do j=j+1
If j=n
then
return true
else
return flase
end if
End if
end