算法模板Latex

代碼:

\begin{algorithm}[t]
	\caption{algorithm caption} %算法的名字
	\hspace*{0.02in} {\bf Input:} %算法的輸入, \hspace*{0.02in}用來控制位置,同時利用 \\ 進行換行
	input parameters A, B, C\\
	\hspace*{0.02in} {\bf Output:} %算法的結果輸出
	output result
	\begin{algorithmic}[1]
		\State some description % \State 後寫一般語句
		\For{condition} % For 語句,需要和EndFor對應
		\State ...
		\If{condition} % If 語句,需要和EndIf對應
		\State ...
		\Else
		\State ...
		\EndIf
		\EndFor
		\While{condition} % While語句,需要和EndWhile對應
		\State ...
		\EndWhile
		\State \Return result
	\end{algorithmic}
\end{algorithm}

效果:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章