同一篇文章下,多个不同的伪代码片段,如何多次重定义require/ensure?

2020-01-06 11:52发布

\usepackage{algorithm} %format of the algorithm \usepackage{algorithmic} %format of the algorithm \u...

\usepackage{algorithm} %format of the algorithm \usepackage{algorithmic} %format of the algorithm \usepackage{multirow} %multirow for format of table \usepackage{amsmath} \usepackage{xcolor} \renewcommand{\algorithmicrequire}{\textbf{Input:}} \renewcommand{\algorithmicensure}{\textbf{Output:}} \begin{algorithm} \caption{Sample algorithm} \label{alg1} \begin{algorithmic}[1] \REQUIRE Text:Today is a good day. Variables:$u,v,w$. $G=(V,E)$ \ENSURE Something... % if-then-else \IF{some condition is true} \STATE do some processing \ELSIF{some other condition is true} \STATE do some different processing \ELSE \STATE do the default actions \ENDIF \REPEAT \STATE carry out some processing \UNTIL{some condition is met} % infinite loop \LOOP \STATE this processing will be repeated forever \ENDLOOP \end{algorithmic} \end{algorithm}