latex算法书写

来源:互联网 发布:win7系统数据恢复 编辑:程序博客网 时间:2024/06/05 21:57

\documentclass[a4paper,12pt]{cctart}
\usepackage{amsmath,amssymb,graphicx,subfigure}
\usepackage{algorithm}
\usepackage{algorithmic}
\title{}
\author{}
\date{}
\textheight=25cm \textwidth=15cm \topmargin=-2cm
\oddsidemargin=0cm \evensidemargin=0cm

\begin{document}
\begin{algorithm}[H]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{algorithmic}[1]
\REQUIRE a network $N:=N(x,y)$ and a zero flow $f$ in $N$
\ENSURE a maximum flow $f$ returned by $2M+1$ iterations
\STATE  set $k=0$ and $s=0$
\IF {$k=0$}
\STATE choose the increment path shown in figure 8-1-1-b
\STATE set $s=s+1$
\ELSE
\STATE choose the increment path shown in figure 8-1-1-c
\STATE set $s=s+1$
\ENDIF
\IF {either $f((u,y))$ or $f((v,y))$ is less than $M$}
\STATE set $k=1-k$
\RETURN to step 2
\ELSE
\STATE do the Max-Flow Min-Cut Algorithm to show that $f$ is a maximum flow
\STATE set $s=s+1$
\ENDIF
\RETURN $(f,s)$ where $s$ means the number of iterations used
\end{algorithmic}
\end{algorithm}
\end{document}

原创粉丝点击