\documentclass{article}
\usepackage{xeCJK}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{algorithm}
$input$:$n$个元素的升序数组$A[1...n]$和元素$x$ \\
$output$:若$x=A[j]$,$1\leqslant j\leqslant n$,则输出$j$,否则输出0
\begin{algorithmic}[1]
\Procedure{BSearch}{}
\State{$low \gets 1 ; high \gets n ; j \gets 0$}
\While{$low \leqslant high$ and $j=0$}
\State{$mid \gets random(low,high)$}
\If{$x=A[mid]$}
\State{$j \gets mid$}
\ElsIf{$x < A[mid]$}
\State{$high \gets (mid-1)$}
\Else
\State{$low \gets (mid+1)$}
\EndIf
\EndWhile
\State\Return{$j$}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}