![算法设计风格的伪代码(Kleinberg & Tardos)](https://linux22.com/image/426717/%E7%AE%97%E6%B3%95%E8%AE%BE%E8%AE%A1%E9%A3%8E%E6%A0%BC%E7%9A%84%E4%BC%AA%E4%BB%A3%E7%A0%81%EF%BC%88Kleinberg%20%26%20Tardos%EF%BC%89.png)
答案1
也许您不需要额外的算法包,tabbing
环境(标准 LaTeX)就足够了。
\documentclass{article}
\newcommand\tab{\hspace{1.5em}}
\begin{document}
{\ttfamily
\begin{tabbing}
\tab\=\tab\=\tab\=\tab\=\tab\=\tab\=\kill
Initially, all $m\in M$ and $w\in W$ are free\\
While there is a man $m$ who is free and hasn't proposed to every woman\\
\>Choose such a man $m$\\
\>Let $w$ be the highest-ranked woman in $m$'s preference list\\
\>\>to whom $m$ has not yet proposed\\
\>If $w$ is free then\\
\>\>$(m,w)$ become engaged\\
\>Else $w$ is currently engaged to $m'$\\
\>\>If $w$ prefers $m'$ to $m$ then\\
\>\>\>$m$ remains free\\
\>\>Else $w$ prefers $m$ to $m'$\\
\>\>\>$(m,w)$ become engaged\\
\>\>\>$m'$ becomes free\\
\>\>Endif\\
\>Endif\\
Endwhile\\
Return the set $S$ of engaged pairs
\end{tabbing}%
}
\end{document}