结构话编程强调的是对流程的控制;

它为面向过程编程提供天然的支持。

Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of subroutinesblock structuresfor and while loops—in contrast to using simple tests and jumps such as the go to statement, which could lead to "spaghetti code" that is difficult to follow and maintain.

Control structures[edit]

Following the structured program theorem, all programs are seen as composed of control structures:

  • "Sequence"; ordered statements or subroutines executed in sequence.
  • "Selection"; one or a number of statements is executed depending on the state of the program. This is usually expressed with keywords such as if..then..else..endif.
  • "Iteration"; a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as whilerepeatfor or do..until. Often it is recommended that each loop should only have one entry point (and in the original structural programming, also only one exit point, and a few languages enforce this).
  • "Recursion"; a statement is executed by repeatedly calling itself until termination conditions are met. While similar in practice to iterative loops, recursive loops may be more computationally efficient, and are implemented differently as a cascading stack.

 

Graphical representation of the three basic patterns — sequence, selection, and repetition — using NS diagrams (blue) and flow charts (green).

Subroutines[edit]

Subroutines; callable units such as procedures, functions, methods, or subprograms are used to allow a sequence to be referred to by a single statement.

Blocks[edit]

Blocks are used to enable groups of statements to be treated as if they were one statement. Block-structured languages have a syntax for enclosing structures in some formal way, such as an if-statement bracketed by if..fias in ALGOL 68, or a code section bracketed by BEGIN..END, as in PL/Iwhitespace indentation as in Python - or the curly braces {...} of C and many later languages.

https://en.wikipedia.org/wiki/Structured_programming

结构化编程-Structured programming的更多相关文章

  1. C++程序结构---1

    C++ 基础教程Beta 版 原作:Juan Soulié 翻译:Jing Xu (aqua) 英文原版 本教程根据Juan Soulie的英文版C++教程翻译并改编. 本版为最新校对版,尚未定稿.如 ...

  2. [3]第二章 C++编程简介

    (本资料均从 internet 上进行收录整理,若要转载,请与原作者联系) 2.1  机器语言.汇编语言和高级语言 程序员用各种编程语言编写指令,有些是计算机直接理解的,有些则需要中间翻译(tranl ...

  3. Reading | 《C++ Primer Plus》(未完待续)

    目录 一.概述和C++简史 1.早期语言的问题 2.面向对象编程OOP 3.泛型编程 二.入门 1.头文件 2.名称空间 3.cout输出 4.C++语句 5.函数 一.概述和C++简史 C++融合了 ...

  4. 文艺编程 Literate Programming

    (译注:这篇文章是 Donald Knuth 一篇1983年的论文:Literate Programming 的介绍部分.有人翻译为“字面编程”,是极其错误的说法,literate 根本就没有“字面” ...

  5. Core Java Volume I — 4.1. Introduction to Object-Oriented Programming

    4.1. Introduction to Object-Oriented ProgrammingObject-oriented programming, or OOP for short, is th ...

  6. Chapter 1 An Overview of Computers and Programming Languages

    Babylon巴比伦 loom织布机 weaver, WHO uses loom to work census: to count the population tabulate: make into ...

  7. 2018-02-27 "Literate Programming"一书摘记之一

    书到后才发现是Knuth的论文集, 第一篇就在网上: Computer programming as an art (1974). 其中"Taste and Style"(品味和风 ...

  8. DCI:The DCI Architecture: A New Vision of Object-Oriented Programming

    SummaryObject-oriented programming was supposed to unify the perspectives of the programmer and the ...

  9. Comparison of programming paradigms

    Main paradigm approaches[edit] The following are widely considered the main programming paradigms, a ...

随机推荐

  1. jq图片懒加载

    jQuery图片延迟加载插件jQuery.lazyload,使用延迟加载在可提高网页下载速度.在某些情况下,它也能帮助减轻服务器负载. 使用方法 引用jquery和jquery.lazyload.js ...

  2. Amaze UI的一点总结

    做一个微信公众号内的网页的时候,用到了Amaze UI,也称妹子UI. 官网上宣称,Amaze UI中国首个开源 HTML5 跨屏前端框架,用下来的感觉是比较类似于bootstrap,都是移动端优先. ...

  3. HTTPie:一个不错的 HTTP 命令行客户端

    转自:http://top.jobbole.com/9682/ HTTPie:一个不错的 HTTP 命令行客户端 HTTPie (读aych-tee-tee-pie)是一个 HTTP 的命令行客户端. ...

  4. Python编程:从入门到实践 - matplotlib篇 - Random Flow

    随机漫游 # random_flow.py 随机漫游 import random class RandomFlow(): """一个生成随机漫游数据的类"&qu ...

  5. Swagger在 NETcore 中的使用

    请参考 https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/getting-started-with-swashbuckle?view=asp ...

  6. 00069_DateFormate

    1.DateFormate类概述 (1)DateFormat 是日期/时间格式化子类的抽象类,它以与语言无关的方式格式化并解析日期或时间.日期/时间格式化子类(如 SimpleDateFormat类) ...

  7. volatile可见性和指令重排

    volatile关键字的2个作用 1.线程的可见性 2.防止指令重排 什么是线程的可见性? 线程的可见性 就是一个线程对一个变量进行更改操作 其他线程获取会获得最新的值. 线程在执行的行 操作主线程的 ...

  8. 记录magento通过csv文件与zip(图片压缩)上传产品到数据库的过程

    1,前台使用input-file type按钮提交文件到magento指定的控制器,controllers获取.csv文件,因为magento是在zend框架上实现的,可以使用如下代码获取文件的上传信 ...

  9. CF43A Football

    CF43A Football 题意翻译 题目大意 两只足球队比赛,现给你进球情况,问哪支队伍赢了. 第一行一个整数nn (1\leq n\leq 1001≤n≤100 ),表示有nn 次进球,接下来n ...

  10. Android漫游记(6)---APP启动之旅(I)

    Android基于Linux2.6+内核,我们看一张图,以对Android系统的架构有个感性的认识. 我们从Kernel层简单说明: 1.Kernel层:基于Linux2.6+内核.同一时候做了一些嵌 ...