添加算法
添加的宏包
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{algpseudocode}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
算法是三线表的形式,左侧自动生成行数,循环结构和if结构是一块整体
常用结构示例
完整代码
\documentclass{article}
\usepackage{hyperref}
%\usepackage{amsmath}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{algpseudocode}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{document}
\begin{algorithm}[H]
\caption{Title}\label{algorithm1}
\SetKwInOut{Input}{input}\SetKwInOut{Output}{output}
\Input{content of input}
\Output{content of ouput}
Xxxxxx\; %普通语句
Xxxxxx\;
Xxxxxx\;
\Repeat{循环结束条件}{
循环体
}
\For{condition}{
for block
}
\uIf{condition}{
then block without end
}
\uElseIf{elseif comment}{
elseif block without end
}
\Else{语句}
\If{condition}{
then block
}
\end{algorithm}
\end{document}