Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{article}
- \usepackage[vlined,ruled,linesnumbered]{algorithm2e}
- \usepackage{algpseudocode}
- \SetKwInput{KwInput}{Input}
- \SetKwInput{KwOutput}{Output}
- \SetKwInput{KwData}{Data}
- \begin{document}
- \begin{algorithm}
- \caption{Example code}
- \KwInput{Your Input}
- \KwOutput{Your output}
- \KwData{Testing set $x$}
- $\sum_{i=1}^{\infty} := 0$
- \tcp*{this is a comment}
- \tcc{Now this is an if...else conditional loop}
- \If{Condition 1}{
- Do Something \\
- \If{sub-condition}{
- Do a lot
- }
- }\ElseIf{Condition 2}{
- Do Otherwise
- \tcc{Now this is a for loop}
- \For{sequence}{
- loop instructions
- }
- }
- \Else{
- Do the rest
- }
- \tcc{Now this is a While loop}
- \While{Condition}{
- do something
- }
- \end{algorithm}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement