伪代码的格式

伪代码的格式

我有代码:

\documentclass[a4paper, 11pt]{article}
\usepackage{comment} % enables the use of multi-line comments (\ifx \fi) 
\usepackage{fullpage} % changes the margin
\usepackage[swedish]{babel}
\usepackage[utf8]{inputenc}
 \usepackage[linesnumbered]{algorithm2e}
\begin{document}
\begin{algorithm}[htb]
\label{alg:algo1}

\KwIn{Objects $O1...On$}
\KwOut{$true$, falls Mehrheitsvotum besteht, sonst $false$}

$counter\leftarrow0$\;
\For {$i=1$ \thinspace to n}{
    \For {$j=1$ \thinspace to n}{
     \If {$O_1=O_j$}{
     $counter \leftarrow counter+1$}
    }
}
\If {$counter\geq n/2$}{
return $true$}
\Else {return $false$}
\end{algorithm}
\end{document}

编译时,每个 for 或 if 都有一些垂直线,循环结束时会显示“end”。我可以删除这些线和结尾吗?谢谢

答案1

根据手册,第 7.4 节所述:

\usepackage[linesnumbered,noline,noend]{algorithm2e}

相关内容