伪代码示例 [英] Pseudo code example

查看:150
本文介绍了伪代码示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手,我正在努力学习它的基础知识.有人可以向我解释伪代码的概念.我已经做了一些研究,但额外的帮助会很棒.例如,制作花生酱和果冻三明治的伪代码会是什么样子?

I am new to programming in general and I am trying to learn the basics of it. Could someone explain me the concept of Pseudo code. I have already done some research but an additional help would be great. As an example, what would pseudo code for making a peanut butter and jelly sandwich would look like?

-谢谢.

推荐答案

伪代码旨在以某种方式描述和描述程序或算法(在大多数情况下只是其中的一部分)的流程、结构和逻辑语句无需分析实际代码就容易理解,没有任何编程知识的人也可以理解.

Pseudo code is meant to describe and describe the flow, structure and logical statements of a program or and algorithm (in most cases only parts of it) in a way that is easy to understand without needing to analyze actual code, and can also be understood by those without any programming knowledge.

伪代码可以由真实的类似代码的示例组成,也可以仅由纯文本组成.

Pseudo code can either consist of real code-like examples, or just pure text.

用于制作 PBJ 的伪代码示例如下所示:

An example of a pseudo code for making a PBJ could look something like this:

MakePBJRoutine(input: peanut butter, jelly, bottom bread, top bread) 
Begin routine:
        Take bottom bread. 
        Spread peanut butter on bottom bread. 
        Spread jelly on bottom bread. 
        If want more jelly:
              Spread jelly on bottom bread. 
        Place top bread slice on bottom bread
        Return finished sandwich
End routine 

同时,它也可以是这个样子.

Meanwhile, it could also look like this.

makePBJroutine(input: P, J, TB, BB; Out: PBJ) {
     BB <- P;
     BB <- J;
     If(BB.J < PreferredJellyAmountConstant){
         BB <- J;
     } 
    PBJ <- (BB <- TB);
    Return PBJ;
}

这篇关于伪代码示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆