\begin{algorithm}[H]\KwData{this text}\KwResult{how to write algorithm with \LaTeX2e }initialization\;\While{not at end of this document}{read current\;\Repeat{this end condition}{do these things\;}\eIf{understand}{go to next section...
LaTeX伪代码及while循环表示 什么是LaTeX伪代码: LaTeX伪代码是一种使用LaTeX语法编写的算法或程序逻辑的表示方法。它主要用于学术论文、技术文档等场合,以便清晰地展示算法流程或程序逻辑,而不必展示具体的编程语言代码。LaTeX提供了多种宏包(如algorithm、algorithmic、algorithm2e等)来支持伪代码的编写。 LaTeX中如何表示...
algorithm用于给伪代码提供一个浮动体环境,防止其换页或其他因素导致的内容中断,从而跨页显示。 algorithmic用于编辑伪代码的内容,一些for、while、if等语句通过该包中的命令进行编写。 algorithmicx可以看作algorithmic的升级版,提供了一些自定义命令 algorithm2e则是独立于algorithmic和algorithmicx的另一套伪代码环境,两套...
\State \textbf{goto} \emph{loop}. \State \textbf{close}; \EndIf \State i←i+max(delta1(string(i)),delta2(j))i←i+max(delta1(string(i)),delta2(j)). \State \textbf{goto} \emph{top}. \EndProcedure \end{algorithmic} \end{algorithm} algorithm2e例子 algorithm2e包可能会...
同样,循环语句如`\WHILE`、`\REPEAT`、`\LOOP`和`\FOR`也需要相应的结束语句。🖥️ 显示结果: 在`algorithm`和`algorithmic`宏包下,你可以直接看到算法的显示结果。这些宏包提供了灵活的排版选项,帮助你更好地组织你的代码。📦 algorithm2e宏包:...
{algorithm} which gives Data: this text A Result: how to write algorithm with L TEX2e initialization; while not at end of this document do read current section; if understand then go to next section; current section becomes this one; else go back to the beginning of current section; end...
45. \EndWhile 46. \For{$i = 0 \to k-1$} 47. \State $Array[left + i] \gets B[i]$ 48. \EndFor 49. \State \Return{$result$} 50. \EndFunction 51. \end{algorithmic} 52. \end{algorithm} 53. \end{document} 1. 2. ...
\begin{algorithm}[H] % \SetAlgoNoLine %去掉之前的竖线 \caption{How to write algorithms} \KwIn{this text} \KwOut{how to write algorithm with \LaTeX2e } initialization; \\ \While{not at end of this document}{ read current; \\ \eIf{understand} { go to next section; \\ current sectio...
\begin{algorithm}[H] % \SetAlgoNoLine %去掉之前的竖线 \caption{How to write algorithms} \KwIn{this text} \KwOut{how to write algorithm with \LaTeX2e } initialization; \\ \While{not at end of this document}{ read current; \\ \eIf{understand} { go to next section; \\ current sectio...
\WHILE{$N\neq0$} \IF{$N$is even} \STATE$X\leftarrowX\timesX$ \STATE$N\leftarrowN / 2$ \ELSE[$N$is odd] \STATE$y\leftarrowy\timesX$ \STATE$N\leftarrowN - 1$ \ENDIF \ENDWHILE \end{algorithmic} \end{algorithm} 问题:The floating objectalgorithmdoesn't behave well with beamer...