为什么我会收到编译器错误?

为什么我会收到编译器错误?
\begin{algorithm}  
  \label{alg:1}  
  \begin{algorithmic}[1] %here [1] says use line numbers every 1 line  
    \INPUT Array $A$ %use math mode liberally  
    \OUTPUT Integer value that repeats in $A$  
    \FORALL {$a \in A$}    
    \FORALL{$b \in A$}    
    \IF {$$A[a]$$ $\equiv$ $$A[b]$$}  
    \RETURN $$A[a]$$  
    \ENDIF  
    \ENDFOR  
    \RETURN No values repeat  
  \end{algorithmic}  
\end{algorithm}  

产生

LaTeX Error: \begin{ALC@g} on input line 74 ended by \end{algori
thmic}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.81       \end{algorithmic}

答案1

可能是因为您错误地使用了 \FORALL。

它应该是

\FORALL{<condition>} \STATE{<text>} \ENDFOR

https://en.wikibooks.org/wiki/LaTeX/Algorithms

相关内容