如何在word中写伪代码

编程知识 更新时间:2023-04-07 00:34:38

如何在word中写伪代码

1.下载texlive

参考

2.下载Aurora

链接:https://pan.baidu/s/1A_IFxdJ6rrpuWUY1DN-YOQ
提取码:ylmo
复制这段内容后打开百度网盘手机App,操作更方便哦

3.设置

打开Aurora的输入界面,在Properties的Packages选项卡中输入:

\documentclass{article}
\usepackage{multirow}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} 

4.伪代码使用介绍

1.模版

\renewcommand{\thealgorithm}{1}  
\begin{algorithm}[H]  
\caption{example}  
\begin{algorithmic}[1]
\Require  {F,P,l} 
\Ensure   {P}       
	\state $sss$
\end{algorithmic}  
\end{algorithm}

这就是一个基础模版,第一行的1是算法1
caption是题目
Require是输入参数
Ensure是输出参数
中间可以写自己要输出的代码
然后点击Refresh就可以更新伪代码

2.使用技巧

文字写$$外边,表达式写里面
在一起连着的字母或者表达式要用{}来表示这是一个整体
f_i i为下标 f_{i+1} i+1为下标
\gets 左赋值
\leq 小于等于
\geq大于等于
\neq不等于
\textbf{and} 会把and变成黑色字体
\mod 取余

for循环

\For{$i=1;i<l-1;i++$} 
	\State  $ f_i \gets f_(i+1) ;$
\EndFor

while循环

  \While{(a$>$b)}  
     \State  state4......  
      \If { c$<$d}  
    	 \State state5......  
      \Else  
    	  \State state6......  
      \EndIf  
       \State state7......  
 \EndWhile  

3.代码示例

 \renewcommand{\thealgorithm}{1}  
\begin{algorithm}[H]  
\caption{example}  
\begin{algorithmic}[1]
\Require  {F,l} 
\Ensure   {P}        
	\For{$i=0;i<l;i++$} 
		\If {$f_i  > f_{i+1}$}  
			\State return $f_{i+1}$;
              \Else  	       
			\If {$f_i \neq 0$}  
				\State return $f_i$;
			\EndIf 
		\EndIf 
		\State $P[i] \gets f_i;//$xxxxxxxxxxxxxxxxx
	\EndFor
	\State Return P;
\end{algorithmic}  
\end{algorithm}

5.插入表格

 \begin{table}
    \centering
    \begin{tabular}{|l|c|c|}\hline
        Setting&\multicolumn{2}{c|}{A4 size paper}\\\hline
        &mm&inches\\
        Top&25&1.0\\
        Bottom&25&1.0\\
        Left&20&0.8\\
        Right&20&0.8\\
        Column Width&82&3.2\\
        Column Spacing&6&0.25\\\hline
    \end{tabular}
    \caption{Margin settings for A4 size paper}
\end{table}

将上面代码复制,然后点Paste from Tex

更多推荐

如何在word中写伪代码

本文发布于:2023-04-07 00:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/9a4d74e9aa0e549dfd8d090ce4050dc6.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   如何在   word   中写伪

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 51400文章数
  • 14阅读数
  • 0评论数