Latex算法伪代码模板

\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
\begin{algorithm}[htb]
\caption{Hierarchical Clustering Alogorithm.}
\label{alg1}
\begin{algorithmic}[1]
\Require Unlabeled data { x i } i = 1 N \left\{x_{i}\right\}_{i=1}^{N} {xi}i=1N; Number of clusters N t N_{t} Nt.
\Ensure N t N_{t} Nt clusters of unlabeled data.
\State Initializing each sample in { x i } i = 1 N \left\{x_{i}\right\}_{i=1}^{N} {xi}i=1N as one cluster;
\label{code1}
\Repeat
\State Finding two clusters C i ∗ C_{i^{*}} Ci, C j ∗ C_{j^{*}} Cj belonging to the nearest pair;
\label{code2}
\State Combining two clusters C i ∗ C_{i^{*}} Ci, C j ∗ C_{j^{*}} Cj into one cluster C C C;
\label{code3}
\Until{Number of clusters = N t N_{t} Nt.}
\label{code4}
\State \Return Final N t N_{t} Nt clusters of unlabeled data.
\end{algorithmic}
\end{algorithm}

你可能感兴趣的:(Latex)