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

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

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. win 2016 添加系统组件注册表,

    Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\ServicingS ...

  2. mac上安装flask详细步骤

    1  在终端输入 macdeMac-mini-62:~ mac$ sudo easy_install pip 2 macdeMac-mini-62:~ mac$ sudo pip install fl ...

  3. node——express实现hello world

    创建文件夹,在文件夹内再创建index.js 1.package.json npm init -y 2.安装 npm install express ---save 3.index.js //入口文件 ...

  4. 训练1-V

    输入2个正整数A,B,求A与B的最大公约数. Input 2个数A,B,中间用空格隔开.(1<= A,B <= 10^9) Output 输出A与B的最大公约数. Sample Input ...

  5. FreeBSD的VIM基本配置

    实现的基本功能 中文解决乱码问题 鼠标右键原样粘贴 最后一次编辑文件后,鼠标位置的记忆 if v:lang =~ "utf8$" || v:lang =~ "UTF-8$ ...

  6. bilibili用户信息查询

    bilibili用户信息查询 http://space.bilibili.com/ajax/member/GetInfo?mid= 后缀为用户mid号 # -*- coding:utf-8 -*- # ...

  7. BigDecimal类(高精度小数)

    位置:java.math.BigDecimal 作用:提供高精度小数数据类型及相关操作 一.基本介绍 BigDecimal为不可变的.任意精度的有符号十进制数,其值为(unscaledValue * ...

  8. 数据库-mongodb-mongod参数说明

    Mongodb启动命令mongod参数说明 mongod的主要参数有: 基本配置 ----------------------------------------------------------- ...

  9. 机房工程-在线式、后备式UPS选择(转载)

    原文网址:http://oa.yesky.com/10/31061510all.shtml#p31061510 1后备式UPS还是在线式UPS? 作为机房设备的一项重要保护措施,UPS起着无可替代的作 ...

  10. CF876A Trip For Meal

    CF876A Trip For Meal 题意翻译 小熊维尼非常喜欢蜂蜜! 所以他决定去拜访他的朋友. 小熊有三个最好的朋友:兔子,猫头鹰和小毛驴,每个人都住在自己的房子里. 每对房屋之间都有蜿蜒的小 ...