算法有误

算法有误
\RequirePackage{amsmath}

\documentclass[runningheads,a4paper]{llncs}

\setcounter{tocdepth}{3}

\usepackage{graphicx}

\usepackage{amssymb}

\usepackage{algorithm}

\usepackage{algorithmicx}

\usepackage{algpseudocode}

\usepackage{titleps}

\usepackage{url}

\begin{document}
    \begin{algorithm}
        \caption{GroupAuth\_KeyExch(Group, 1, n)}
        \begin{algorithmic}
            Let’s assume Group = \{UE1, UE2, … , UEn\} and n represents the number of groups.
            Aim of this algorithm is to authenticate all the devices and establish a session key for the defined Group.
                    \{ 
            for i = 1 to n do
            \{
            Recive\_Msgi1 = null;
            Recive\_Msgi2 = null;
            Obtained\_Keyi = False;
            \}
        \end{algorithmic}
    \end{algorithm}
\end{document}

收到此错误

答案1

你可能正在寻找类似的东西。是的,这种语法可能相当麻烦。有时在逐字环境中编写它可能更容易

    \begin{algorithmic}
      \State Let’s assume Group = \{UE1, UE2, … , UEn\} and n represents the number of groups.
      \State Aim of this algorithm is to authenticate all the devices and establish a session key for the defined Group.
      \For{i = 1 to n}
      \State \{
      \State Recive\_Msgi1 = null;
      \State Recive\_Msgi2 = null;
      \State Obtained\_Keyi = False;
      \State \}
      \EndFor
    \end{algorithmic}

相关内容