答案1
使用algorithm2e
:
\documentclass{article}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\DontPrintSemicolon
\SetKwInput{Input}{Input}
\SetKwInput{Output}{Output}
\SetKw{To}{ to }
\SetKw{Print}{Print }
\begin{document}
\begin{algorithm}
\caption{PrintK}
\Input{Integers $n_1, n_2, \ldots, n_m$ each of which is $\geq 1$}
\Output{None}
$k \gets 0$\;
\For{$i_1 \gets 1 \To n_1$}{%
\For{$i_2 \gets 2 \To n_2$}{%
$\cdot$\;
$\cdot$\;
$\cdot$\;
\For{$i_m \gets 1 \To n_m$}{%
$k \gets k + 1$\;
}
}
}
\Print $k$
\end{algorithm}
\end{document}