0

I want to write this algorithm:

for(i=0;i<nbOfPedCurr;i++){
 for(j=0;j<nbOfPedPrev;j++){
    int idCurr=idCurrentFrame;
    int idPrev=idPrevFrame;
    if(idCurr==idPrev){
         CurrObj=extract(CurrMask,CurrPos);
         PrevObj=extract(PrevFrame,PrevPos);
         xor(CurrObj,PrevObj,dest);
         Sum=Sum+dest;
    }
   }
  }

Can any one help me to write it?

3

I am not sure what programming language you are using but you could look at the listings package. This will allow you to typeset programming code.

So you can do something that looks like:

\documentclass{standalone}
\usepackage{listings}

\begin{document}
\lstset{language=C++}          % Set your language (you can change the language for each code-block optionally)
\begin{lstlisting}[frame=single]  % Start your code-block
for(i=0;i<nbOfPedCurr;i++){
    for(j=0;j<nbOfPedPrev;j++){
        int idCurr=idCurrentFrame;
        int idPrev=idPrevFrame;
        if(idCurr==idPrev){
            CurrObj=extract(CurrMask,CurrPos);
            PrevObj=extract(PrevFrame,PrevPos);
            xor(CurrObj,PrevObj,dest);
            Sum=Sum+dest;
        }
    }
}
\end{lstlisting}
\end{document}

And that should help with typesetting and syntax highlighting.

  • Can I add a caption to this algorithm? – para May 26 '16 at 4:32
  • @para \begin{lstlisting}[frame=single,caption={whatever}] – Torbjørn T. May 26 '16 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.