首先是在头文件中加上
\usepackage{algorithm, algorithmic}
算法框架
\begin{algorithm}
\renewcommand{\algorithmicrequire}{\textbf{Require:}}
\caption{timu}
\label{alg:1}
\begin{algorithmic}[1]
\REQUIRE
\quad
\\bianliang $I(x,y)$,
\STATE computer $C[(x_{m},y_{m}),d_{i}]$ as Equation 1
\end{algorithmic}
\end{algorithm}
效果
timu 为题目,可以自行修改
Require 可以改为Input或者Output
其中\STATE为换行
IF语句
\IF{$di=dm$}
\STATE step$ \leftarrow [U_{max}]$
\ELSE[$N$ is odd]
\STATE step=1
\ENDIF
效果
FOR语句
\FOR{$i=1$ to $n$}
\STATE $//$ Your source here;
\ENDFOR
效果
WHILE语句
\WHILE {$a>0$}
\STATE your idea;
\ENDWHILE
效果