1\documentclass{article}
2\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
3
4\begin{document}
5
6\begin{algorithm}[H]
7 \DontPrintSemicolon
8 \KwData{Input data}
9 \KwResult{Result of the algorithm}
10
11 \SetKwInput{KwInput}{Input}
12 \SetKwInput{KwOutput}{Output}
13
14 \KwInput{Input parameters}
15 \KwOutput{Output value}
16
17 \BlankLine
18
19 initialization\;
20 \While{Condition}{
21 logic1\;
22 \eIf{Subcondition}{
23 logic2\;
24 }{
25 logic3\;
26 }
27 logic4\;
28 }
29
30 \caption{Example algorithm using algorithm2e}
31\end{algorithm}
32
33\end{document}
1\documentclass{article}
2\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
3
4\begin{document}
5
6\begin{algorithm}[H]
7 \DontPrintSemicolon
8 \KwData{Input data}
9 \KwResult{Result of the algorithm}
10
11 \SetKwInput{KwInput}{Input}
12 \SetKwInput{KwOutput}{Output}
13
14 \KwInput{Input parameters}
15 \KwOutput{Output value}
16
17 \BlankLine
18
19 initialization\;
20 \While{Condition}{
21 logic1\;
22 \eIf{Subcondition}{
23 logic2\;
24 }{
25 logic3\;
26 }
27 logic4\;
28 }
29
30 \caption{Example algorithm using algorithm2e}
31\end{algorithm}
32
33\end{document}
展示效果: