\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
\caption{family}
\hspace*{\algorithmicindent} \textbf{Input}\\
\hspace*{\algorithmicindent} \textbf{Output}
\begin{algorithmic}[1]
\State sing
\While dark
\State radar
\If {not found}
\State does
\ElsIf {pick}
\State case \If do
\State did
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}
答案1
你没有关闭其中一个 If 语句。此代码有效:
\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
\caption{family}
\hspace*{\algorithmicindent}
\textbf{Input}\
\hspace*{\algorithmicindent}
\textbf{Output}
\begin{algorithmic}[1]
\State sing
\While dark
\State radar
\If {not found}
\State does
\ElsIf {pick}
\State case
\If do
\State
did
\EndIf
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}
另外,请查看如何提出好的问题?并格式化您的代码以便于阅读。希望我能帮到您。