이 알고리즘에 대한 도움이 필요하세요?

이 알고리즘에 대한 도움이 필요하세요?

LaTeX에서 알고리즘을 만들려고 합니다. 예를 들어, 나는 이 템플릿을 사용하고 있으며 이 단계에 대한 도움을 원합니다.

첫 번째 루프mik=aik/akk;

그리고 두 번째 루프aij=aij- mikakj;

그리고 마지막으로 이 마지막 루프로 마무리합니다.

bi=bi=mikbk;

LaTeX 코드로 이것을 작성하는 방법은 무엇입니까?

\section{The algorithm which solves the method Gaussian elimination}
\For{$k$=1$:$1$n-1$}{
    \For{$i=k+1:1:n$}\;
       {write the first loop here}{
      \For{}
      {write the second loop here}
        instructions1\; finish here
        instructions2\;
      {final loop there}
    }{
        instructions3\;
    }
}
\caption{How to write algorithms}

이 문제로 인해 죄송합니다. 이 문제를 해결하도록 도와주세요.

답변1

다음은 시작점 역할을 할 수 있습니다.

\documentclass{article}
\usepackage[ruled]{algorithm2e}

\begin{document}
\begin{algorithm}[H]
    \caption{Test algorithm}
    \SetAlgoLined
    \For{contition}{
        \For{some text here}{
            some text\\
            \For{other stuff}{
                whatever comes here
            }
         some more text
         }
    }

\end{algorithm}
\end{document}

답변2

\begin{algorithm}[H]
\caption{Test algorithm}
\SetAlgoLined
\For{$k=1:1:n-1$}{
    \For{$i=k+1:1:n$}{
          $m_{i}{k}=a_{i}{k}/a_{k}{k}$\\
        \For{other stuff}{
            $a_{i}{j}=a_{i}{j}-m_{i}{k}a_{k}{j};$\\
        }
        $b_{i}=b_{i}-m_{i}{k}b_{k};$
    }
}\end{algorithm}

맞다

관련 정보