Skip to content

Commit 6a2b43e

Browse files
committed
Update algorithm2e formats
1 parent ecc5285 commit 6a2b43e

3 files changed

Lines changed: 987 additions & 18 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
\input{regression-test.tex}
2+
\documentclass[fontset=fandol]{ustcthesis}
3+
4+
\usepackage{algorithm2e}
5+
6+
7+
\begin{document}
8+
9+
\START
10+
\showoutput
11+
12+
\frontmatter
13+
\listofalgorithms
14+
\clearpage
15+
\OMIT
16+
17+
\mainmatter
18+
\chapter{标题}
19+
\clearpage
20+
21+
\TIMO
22+
\begin{algorithm}
23+
\caption{计算 $y = x^n$}
24+
\label{alg1}
25+
\SetKwInOut{Input}{输入}
26+
\SetKwInOut{Output}{输出}
27+
28+
\Input{$n \geq 0 \vee x \neq 0$}
29+
\Output{$y = x^n$}
30+
31+
$y \leftarrow 1$\;
32+
\eIf{$n < 0$}{
33+
$X \leftarrow 1 / x$\;
34+
$N \leftarrow -n$\;
35+
}{
36+
$X \leftarrow x$\;
37+
$N \leftarrow n$\;
38+
}
39+
40+
\While{$N \neq 0$}{
41+
\eIf{$N$ is even}{
42+
$X \leftarrow X \times X$\;
43+
$N \leftarrow N / 2$\;
44+
}{
45+
% \tcp*{$N$ is odd}
46+
$y \leftarrow y \times X$\;
47+
$N \leftarrow N - 1$\;
48+
}
49+
}
50+
\end{algorithm}
51+
52+
\clearpage
53+
\OMIT
54+
\end{document}

0 commit comments

Comments
 (0)