ChatGPT生成的Latex伪代码通用模版
【代码】ChatGPT生成的Latex伪代码通用模版。
·
\documentclass{article}
\usepackage{amsmath,amsfonts}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{A Generic Pseudocode Example}
\textbf{Input:}
\begin{itemize}
\item An input value $x$.
\end{itemize}
\textbf{Output:}
\begin{itemize}
\item An output value $y$.
\end{itemize}
\textbf{Initialization:}
\begin{itemize}
\item Initialize a variable $z$ to 0.
\end{itemize}
\begin{algorithmic}[1]
\State $z \leftarrow 0$ \Comment{Initialization}
\If{$x$ is even}
\State $y \leftarrow x / 2$ \Comment{Compute the result for even input}
\Else
\State $y \leftarrow 3x + 1$ \Comment{Compute the result for odd input}
\EndIf
\For{$i$ from 1 to 10}
\State Perform some computation with $i$
\EndFor
\While{$y$ is not equal to 1}
\State Perform some repetitive computation
\State $y \leftarrow y - 1$
\EndWhile
\Return $y$ \Comment{Return the final result}
\end{algorithmic}
\end{algorithm}
\end{document}
更多推荐
已为社区贡献1条内容
所有评论(0)