数组排序判定

 写一个通用方法用于判定给定的数组是否已排好序

Algorithm compare(a,n)
  Begin 
   j=1;
    while
       (j=a[j+1])
    do j=j+1
    If j=n
      then
        return true
    else 
         return flase
       end if
     End if
end
   

 

你可能感兴趣的:(数组排序判定)