ieee会议latex模板,伪代码写法

%\usepackage{algorithmic}
% algorithmic.sty was written by Peter Williams and Rogerio Brito.
% This package provides an algorithmic environment fo describing algorithms.
% You can use the algorithmic environment in-text or within a figure
% environment to provide for a floating algorithm. Do NOT use the algorithm
% floating environment provided by algorithm.sty (by the same authors) or
% algorithm2e.sty (by Christophe Fiorio) as the IEEE does not use dedicated
% algorithm float types and packages that provide these will not provide
% correct IEEE style captions. The latest version and documentation of
% algorithmic.sty can be obtained at:
% http://www.ctan.org/pkg/algorithms
% Also of interest may be the (relatively newer and more customizable)
% algorithmicx.sty package by Szasz Janos:
% http://www.ctan.org/pkg/algorithmicx
我本来想用algorithmic的,但是那个实在是不好看,下面贴一个简单版本的algorithmic

\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}

% 中略

\begin{figure}[!t]
  \begin{algorithm}[H]
    \caption{Caption}
    \label{alg1}
    \begin{algorithmic}
      \Require args $x_i$
      \Ensure total $s$
      \State $s \leftarrow 0$
      \For{$i=1,\cdots,n$}
        \State $s \leftarrow s + x_i$
      \EndFor
      \State \Return $s$
    \end{algorithmic}
  \end{algorithm}
\end{figure}

下面是我用figure和algorithm2e写的

\usepackage[ruled,linesnumbered]{algorithm2e}

\usepackage{algpseudocode}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
%中略
\begin{figure}[!t]
		\removelatexerror
		\begin{algorithm}[H]
			\caption{hehh}
			\LinesNumbered
			\KwIn{FFT Bins $B_{1}, B_{2}, B_{3}, ..., B_{n}$}
			\KwOut{Event start point $S$, end point $E$}
			\For{i=1:n}{	
				\eIf{max($B_{i}$) : max($B_{(i+4)}$)$>$-80}{
					$S$=i; \tcp*{Start Point}
					\For{j=S:n}{
						\eIf{max($B_{j}$) : max($B_{(j+4)}$)$<$-100}{
							$E$=j; \tcp*{End Point}
							Return [$S,E$];
						}{j++;}
					}
				}{
					i++;}
			}
		\end{algorithm}
	\end{figure}




跑出来是这样的
在这里插入图片描述

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值