algorithm
我使用和包编写了算法algorithmic
,但我总是得到最后一行返回 0。我尝试使用这个解决方案,但我无法让它工作。下面是我使用的算法代码和包。
\documentclass[conference,a4paper]{IEEEtran}
\usepackage{booktabs} % For formal tables
\usepackage{nameref}% Only if hyperref isn't loaded
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx,url}
\ifCLASSOPTIONcompsoc
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\else
\usepackage[caption=false,font=footnotesize]{subfig}
\fi
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage[autostyle=false, style=english]{csquotes}
\usepackage{spreadtab}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage[noadjust]{cite}
\usepackage[nolist]{acronym}
\usepackage{enumerate}
\usepackage{algorithm2e}
\usepackage{pgfplots}
\usepackage{algorithmic}
\usepackage{algorithm,algpseudocode,float}
\usepackage{lipsum}
\makeatletter
\newenvironment{breakablealgorithm}
{% \begin{breakablealgorithm}
\begin{center}
\refstepcounter{algorithm}% New algorithm
\hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
\renewcommand{\caption}[2][\relax]{% Make a new \caption
{\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
\ifx\relax##1\relax % #1 is \relax
\addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##2}%
\else % #1 is not \relax
\addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##1}%
\fi
\kern2pt\hrule\kern2pt
}
}{% \end{breakablealgorithm}
\kern2pt\hrule\relax% \@fs@post for \@fs@ruled
\end{center}
}
\makeatother
\usepackage{booktabs, caption, makecell}
\renewcommand\theadfont{\bfseries}
\usepackage{threeparttable}
\usepackage{footnote}
\begin{document}
\begin{algorithm}[H]
\caption{EtHash mining algorithm}
\begin{algorithmic}[1]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\REQUIRE daggerset, params, block
\ENSURE nonce
\STATE $nonce=randint(0,2$**$64)$
\STATE $result = hashimoto(daggerset,$ \\ $get\_dagsize(params,block), params,$ \\ $decode\_int(block.prevhash), nonce);$
\IF {$result * params$["diff"] $< 2$**$256$}
\STATE $break;$
\ENDIF
\STATE $nonce = nonce + 1;$
\IF {$nonce >= 2$**$64$}
\STATE $nonce = 0;$
\ENDIF
\STATE $return$ $nonce;$
\end{algorithmic}
\end{algorithm}
\end{document}
输出如下:
答案1
您正在使用algorithm
和;删除和的algorithmic
加载。algorithm2e
algpseudocode