以下算法有什么问题?
\documentclass{ws-ijseke}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{lscape}
\usepackage{tcolorbox}
\usepackage[super]{nth}
\usepackage{zed-csp}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm}
\begin{algorithm}
\caption{Initialization}
\begin{algorithmic}[1]
\Require Source Code of a Software Systems $S$
\Ensure List of MMR suggestions those do not break applications after refactoring
\State $A \gets$ AST of $S$
\State $M$ $\leftarrow$ List of methods from $A$
\State $RClass$ $\leftarrow$ List of Regular classes of $S$
\State $TClass$ $\leftarrow$ List of UnitTest classes of $S$
\State $LMMRS$ $\leftarrow$ $\emptyset$
\For {($m$ $\in$ $M$)}
\State $maxCallFromTarget \gets 0$\
\For {($t$ $\in$ $RClass$)}
\If {$t$ != $m.sourceClass$}
\State $callFromTarget$ $\leftarrow$ Number of entities $m$ uses from $t$
\If {$maxCallFromTarget$ $<$ $callFromTarget$}
\State $m.targetClass$ $\leftarrow$ $t$
\State $maxCallFromTarget$ $\leftarrow$ $callFromTarget$
\EndIf
\EndIf
\EndFor
\EndFor
\end{algorithmic}
\end{algorithm}
我收到以下错误:
- 缺少插入 $。
- 插入\如果缺失}。
- \If {$ Extra },或者忘记了 $。
- \如果 {$t$ != $m.sourceClass$}
答案1
不算好,但有点……
\documentclass{article}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{lscape}
\usepackage{tcolorbox}
\usepackage[noend]{algpseudocode}
\usepackage[super]{nth}
\usepackage{algorithm}
\let\aif\If
\usepackage{zed-csp}
\begin{document}
\begin{algorithm}
\caption{Initialization}
\begin{algorithmic}[1]
\Require Source Code of a Software Systems $S$
\Ensure List of MMR suggestions those do not break applications after refactoring
\State $A \gets$ AST of $S$
\State $M$ $\leftarrow$ List of methods from $A$
\State $RClass$ $\leftarrow$ List of Regular classes of $S$
\State $TClass$ $\leftarrow$ List of UnitTest classes of $S$
\State $LMMRS$ $\leftarrow$ $\emptyset$
\For {($m$ $\in$ $M$)}
\State $maxCallFromTarget \gets 0$\
\For {($t$ $\in$ $RClass$)}
\aif {$t$ != $m.sourceClass$}
\State $callFromTarget$ $\leftarrow$ Number of entities $m$ uses from $t$
\aif {$maxCallFromTarget$ $<$ $callFromTarget$}
\State $m.targetClass$ $\leftarrow$ $t$
\State $maxCallFromTarget$ $\leftarrow$ $callFromTarget$
\EndIf
\EndIf
\EndFor
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
首先加载算法,复制宏,然后加载zed-csp。
结果: