示例1
\begin{algorithm}[H]
\caption{algorithm1}
\label{your label}
\begin{algorithmic}[1]
\Require
Enter .....;
\Ensure
Outpur......
\State state1......
\State state2......
\State state3......
\While{(a$>$b)}
\State state4......
\If { c$<$d}
\State state5......
\Else
\State state6......
\EndIf
\State state7......
\EndWhile
\For{aaa}
\State state8......
\EndFor
\end{algorithmic}
\end{algorithm}
示例2(中文显示)
\floatname{algorithm}{{算法}}
\renewcommand{\algorithmicrequire}{\textbf{输入:}}
\renewcommand{\algorithmicensure}{\textbf{输出:}}
\begin{CJK}{GBK}{song}
\renewcommand{\thealgorithm}{2}%算法编号(2可以换成别的数字)
\begin{algorithm}[H]
\caption{算法名}
\label{ABCLFRS}
\begin{algorithmic}[1]%每行前都显示数字
\Require 输入参数解释
\Ensure 输出结果解释
\State 语句一
\State 语句二
\State $\cdots\cdots$
\State 语句三
\end{algorithmic}
\end{algorithm}
\end{CJK}