来源:https://blog.csdn.net/lqhbupt/article/details/8723478

导入包

\usepackage{algorithm}
\usepackage{algorithmic}

带行号算法伪代码

\begin{algorithm}[h]
  \caption{An example for format For \& While Loop in Algorithm}
  \begin{algorithmic}[1]
  \FOR{each $i \in [1,9]$}
  \STATE initialize a tree $T_{i}$ with only a leaf (the root);\
  \STATE $T=T \cup T_{i};$\
  \ENDFOR
  \FORALL {$c$ such that $c \in RecentMBatch(E_{n-1})$} 
  \label{code:TrainBase:getc}
  \STATE $T=T \cup PosSample(c)$; 
  \label{code:TrainBase:pos}
  \ENDFOR
  \FOR{$i=1$; $i<n$; $i++$ }
  \STATE $//$ Your source here;
  \ENDFOR
  \FOR{$i=1$ to $n$}
  \STATE $//$ Your source here;
  \ENDFOR
  \STATE $//$ Reusing recent base classifiers. 
  \label{code:recentStart}
  \WHILE {$(|E_n| \leq L_1 )and( D \neq \phi)$}
  \STATE Selecting the most recent classifier $c_i$ from $D$;
  \STATE $D=D-c_i$;
  \STATE $E_n=E_n+c_i$;
  \ENDWHILE 
  \label{code:recentEnd}
  \end{algorithmic}
  \end{algorithm}

效果:

【LaTeX】算法栏

相关文章:

  • 2021-05-24
  • 2022-12-23
  • 2021-10-26
  • 2021-10-07
  • 2021-05-29
  • 2021-12-23
  • 2022-12-23
  • 2021-11-04
猜你喜欢
  • 2022-12-23
  • 2021-04-29
  • 2022-12-23
  • 2021-12-19
  • 2021-10-23
  • 2021-06-15
  • 2022-12-23
相关资源
相似解决方案