Algorithm example 1:

Screen Shot 2017-09-16 at 12.34.40 AM.png

Code:

Screen Shot 2017-09-16 at 12.35.01 AM.png

Package:

Screen Shot 2017-09-16 at 12.35.30 AM.png


Algorithm example 2:

Screen Shot 2017-09-16 at 12.34.51 AM.png

Code:

Screen Shot 2017-09-16 at 12.35.08 AM.png


% Algorithm example 1:
Example 1:\cite{algo} \\
\begin{algorithm}[H]
 \KwData{this text}
 \KwResult{how to write algorithm with \LaTeX2e }
 initialization\;
 \While{not at end of this document}{
  read current\;
  \eIf{understand}{
   go to next section\;
   current section becomes this one\;
   }{
   go back to the beginning of current section\;
  }
 }
 \caption{How to write algorithms}
\end{algorithm}

% Algorithm example 2:
Example 2:\cite{algo} \\
\begin{algorithmic}
\STATE $i\gets 10$
\IF {$i\geq 5$} 
        \STATE $i\gets i-1$
\ELSE
        \IF {$i\leq 3$}
                \STATE $i\gets i+2$
        \ENDIF
\ENDIF 
\end{algorithmic}


Reference:

[1] https://www.sharelatex.com/learn/algorithms

arrow
arrow
    文章標籤
    latex
    全站熱搜
    創作者介紹
    創作者 ytl0821 的頭像
    ytl0821

    YT Lee's simple notes

    ytl0821 發表在 痞客邦 留言(0) 人氣()