Advertisement
epsilon413

Latex-Question5

Apr 19th, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 0.92 KB | Source Code | 0 0
  1. \documentclass{article}
  2. \usepackage[vlined,ruled,linesnumbered]{algorithm2e}
  3. \usepackage{algpseudocode}
  4.  
  5.  
  6. \SetKwInput{KwInput}{Input}
  7. \SetKwInput{KwOutput}{Output}
  8. \SetKwInput{KwData}{Data}
  9.  
  10. \begin{document}
  11.  
  12.  
  13.  
  14. \begin{algorithm}
  15.    \caption{Example code}
  16.    \KwInput{Your Input}
  17.    \KwOutput{Your output}
  18.    \KwData{Testing set $x$}
  19.  
  20.    $\sum_{i=1}^{\infty} := 0$
  21.    \tcp*{this is a comment}
  22.    \tcc{Now this is an if...else conditional loop}
  23.    \If{Condition 1}{
  24.        Do Something \\
  25.        \If{sub-condition}{
  26.            Do a lot
  27.        }
  28.    }\ElseIf{Condition 2}{
  29.            Do Otherwise
  30.            \tcc{Now this is a for loop}
  31.            \For{sequence}{
  32.            loop instructions
  33.            }
  34.        }
  35.    \Else{
  36.        Do the rest
  37.    }
  38.    \tcc{Now this is a While loop}
  39.    \While{Condition}{
  40.        do something
  41.    }
  42.  
  43. \end{algorithm}
  44.  
  45. \end{document}
  46.  
Tags: LaTeX
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement