《C语言数据结构设计1》由会员分享,可在线阅读,更多相关《C语言数据结构设计1(10页珍藏版)》请在人人文库网上搜索。

1、Chapter 1 PROGRAMMING PRINCIPLES 1. Introduction:Problems with large programs 2. The Game of Life (acontinuing example 3. Programming style (aNames (bDocumentation and format (cRe?nement and modularity 4. Coding, testing, and further re?nement (aStubs (bInput and Output (cDrivers (dProgram Testing 5。

2、. References Problems of Large Programs 1. The patchwork approach 2. Problem speci?cation 3. Program organization 4. Data organization and data structures 5. Algorithm selection and analysis 6. Debugging 7. Testing 8. Maintenance Rules for the Game of Life 1. The neighbors of a given cell are the ei。

3、ght cells that touch it vertically, horizontally, or diagonally. Every cell is either living or dead. 2. A living cell stays alive in the next generation if it has either 2or 3living neighbors; it dies if it has 0, 1, 4, or more living neighbors. 3. A dead cell becomes alive in the next generation i。

4、f it has ex-actly three neighboring cells, no more or fewer, that are al-ready alive. All other dead cells remain dead in the next gen-eration. 4. All births and deaths take place at exactly the same time, so that a dying cell can help to give birth to another, but cannot prevent the death of others。

5、 by reducing overcrowding, nor can cells being born either preserve or kill cells living in the previous generation. and Examples of Life Con?gurations (j(k (l Algorithm for the Life Game Initialize an array called map to contain the initial con?guration of living cells. Repeat the following steps f。

6、or as long as desired: For each cell in the array do the following: Count the number of living neighbors of the cell. If the count is 0, 1, 4, 5, 6, 7, or 8, then set the corresponding cell in another array called newmap to be dead; if the count is 3, then set the corresponding cell to be alive; and。

7、 if the count is 2, then set the corresponding cell to be the same as the cell in array map (sincethe status of a cell with count 2does not change. Copy the array newmap into the array map . Print the array map for the user. Guidelines for Choosing Names 1. Give special care to the choice of names f。

8、or functions, con-stants, and all global variables and types used in different parts of the program. 2. Keep the names simple for variables used only brie?y and locally. 3. Use common pre?xes or suf?xes to associate names of the same general category. 4. Avoid deliberate misspellings and meaningless。

9、 suf?xes to ob-tain different names. 5. Avoid choosing cute names whose meaning has little or noth-ing to do with the problem. 6. Avoid choosing names that are close to each other in spelling or otherwise easy to confuse. 7. Be careful in the use of the letter “ l ” (smallell, “ O ” (capital oh and 。

10、“ 0” (zero. Programming Precept Always name your variables and functions with the greatest care, and explain them thoroughly. Documentation Guidelines 1. Place a prologue at the beginning of each function with (aIdenti?cation (programmers name, date, version. (bStatement of the purpose of the functi。

11、on and method used. (cChanges the function makes and what data it uses. (dReference to further documentation for the program. 2. When each variable, constant, or type is declared, explain what it is and how it is used. 3. Introduce each signi?cant part of the program with a state-ment of purpose. 4.。

12、 Indicate the end of each signi?cant section. 5. Avoid comments that parrot what the code does or that are meaningless jargon. 6. Explain any statement that employs a trick or whose meaning is unclear. Better still, avoid such statements. 7. The code itself should explain how the program works. The 。

13、documentation should explain why it works and what it does. 8. Be sure to modify the documentation along with the program. Programming Precept Keep your documentation concise but descriptive. Programming Precept The reading time for programs is much more than the writing time. Make reading easy to d。

14、o. Re?nement and Modularity Top-down design and re?nement: Programming Precept Dont lose sight of the forest for its trees. Division of work among functions: Programming Precept Each function should do only one task, but do it well. Programming Precept Each function should hide something. Programmin。

15、g Precept Include precise preconditions and postconditions with every function that you write. Categories of Data Used in Functions Input parameters Output parameters Inout parameters Local variables Global variables Programming Precept Keep your connections simple. Avoid global variables whenever p。

16、ossible. Programming Precept Never cause side effects if you can avoid it. If you must use global variables, document them thoroughly. Programming Precept Keep your input and output as separate functions, so they can be changed easily and can be custom-tailored to your computing system. Debugging an。

17、d Testing Methods for debugging: 1. Structured walkthrough 2. Snapshots 3. Scaffolding 4. Static analyzer Programming Precept The quality of test data is more important than its quantity. Programming Precept Program testing can be used to show the presence of bugs, but never their absence. Methods f。

18、or program testing: 1. The black-box method: (a Easy values (b Typical, realistic values (c Extreme values (d Illegal values 2. The glass-box method: Trace all the paths through the program. 3. The ticking-box method: Dont do anythingJust hope for the best! Debugging and Testing Transp. 11, Sect. 1.。

19、4, Coding, Testing, and Further Renement 239 1997 Prentice-Hall, Inc., Upper Saddle River, N.J. 07458 Data Structures and Program Design In C, 2nd. ed. Execution Paths switch a case 1: x = 3; break; case 2: if (b = 0 x = 2; else x = 3; x = 4; break; case 3: while (c 0 process (c; break; a = 1 a = 2 。

20、b = 0 b != 0 a = 3 x = 2; x = 4; while (c 0 process (c; a = 1 a = 2 b = 0 a = 2 b != 0 a = 3 x = 3; x = 2; x = 4; while (c 0 process (c; Path 1 Path 2 Path 3 Path 4 Execution Paths Transp. 12, Sect. 1.4, Coding, Testing, and Further Renement 240 1997 Prentice-Hall, Inc., Upper Saddle River, N.J. 074。

21、58 Data Structures and Program Design In C, 2nd. ed. R Pentomino Cheshire Cat Virus Tumbler Barber Pole Harvester The Glider Gun Life congurations Transp. 13, Sect. 1.4, Coding, Testing, and Further Renement 241 1997 Prentice-Hall, Inc., Upper Saddle River, N.J. 07458 Data Structures and Program Des。

22、ign In C, 2nd. ed. Pointers and Pitfalls 1. Understand your problem before you decide how to solve it. 2. Understand the algorithmic method before you start to program. 3. Divide the problem into pieces and think of each part separately. 4. Keep your functions short and simple. 5. Include careful do。

23、cumentation with each function. 6. Write down precise preconditions and postconditions for every function. 7. Include error checking to check that the preconditions hold. 8. Every time you use a function, verify that its preconditions will hold. 9. Use stubs and drivers, black-box and glass-box test。

24、ing. 10. Use plenty of scaffolding to help localize errors. 11. In programming with arrays, be wary of index values that are off by 1. 12. Keep your programs well-formatted as you write them. 13. Keep your documentation consistent with your code. 14. Explain your program to somebody else. 15. Remember the Programming Precepts! Pointers and Pitfalls Transp. 14, Chapter 1, Programming Principles 242 1997 Prentice-Hall, Inc., Upper Saddle River, N.J. 07458 Data Structures and Program Design In C, 2nd. ed.。

c语言数据结构设计,C语言数据结构设计1相关推荐

  1. c语言编程运动会分数统计系统,东华大学数据结构设计C语言运动会分数统计系统...

    东华大学数据结构设计C语言运动会分数统计系统 东华大学数据结构设计 C 语言运动会分数统计系统东华大学数据结构课程设计 实验报告实验名称: 运动会分数统计系统指导教师:学生姓名:学生学号:实验日期:1 ...

  2. 《数据科学R语言实践:面向计算推理与问题求解的案例研究法》一一2.1 引言...

    本节书摘来自华章计算机<数据科学R语言实践:面向计算推理与问题求解的案例研究法>一书中的第2章,第2.1节,作者:[美] 德博拉·诺兰(Deborah Nolan) 邓肯·坦普·朗(Dun ...

  3. 手把手 | 教你爬下100部电影数据:R语言网页爬取入门指南

    前言 网页上的数据和信息正在呈指数级增长.如今我们都使用谷歌作为知识的首要来源--无论是寻找对某地的评论还是了解新的术语.所有这些信息都已经可以从网上轻而易举地获得. 网络中可用数据的增多为数据科学家 ...

  4. Django模板、配置文件、静态文件及案例实现(创建模板、设置模板查找路径、模板接收视图传入的数据、模板处理数据、BASE_DIR、DEBUG、本地语言与时区、App应用配置)

    1.Django模板 网站如何向客户端返回一个漂亮的页面呢? 漂亮的页面需要html.css.js. 可以把这一堆字段串全都写到视图中, 作为HttpResponse()的参数,响应给客户端. 存在的 ...

  5. livechart 只显示 y 值_基于Python语言的SEGY格式地震数据读取与显示编程

    敬请关注<地学新视野> 摘要:本文简单介绍了SEG-Y地震数据文件格式,以及如何用Python语言编写读写SEG-Y格式的地震数据并绘制地震剖面,其中用到了Segyio和matplotli ...

  6. R语言ggplot2可视化:ggplot2可视化时间序列数据并在末尾数据点添加数值标签(number label)

    R语言ggplot2可视化:ggplot2可视化时间序列数据并在末尾数据点添加数值标签(number label) 目录

  7. R语言使用basename函数获取数据链接地址中的文件名称(removes all of the path up to and including the last path separator )

    R语言使用basename函数获取数据链接地址中的文件名称(removes all of the path up to and including the last path separator (i ...

  8. R语言ggplot2可视化:使用长表数据(窄表数据)( Long Data Format)可视化多个时间序列数据、在同一个可视化图像中可视化多个时间序列数据(Multiple Time Series)

    R语言ggplot2可视化:使用长表数据(窄表数据)( Long Data Format)可视化多个时间序列数据.在同一个可视化图像中可视化多个时间序列数据(Multiple Time Series) ...

  9. R语言使用caret包的preProcess函数进行数据预处理:对所有的数据列进行YeoJohnson变换(将非正态分布数据列转换为正态分布数据、可以处理负数)、设置参数为YeoJohnson

    R语言使用caret包的preProcess函数进行数据预处理:对所有的数据列进行YeoJohnson变换(将非正态分布数据列转换为正态分布数据.可以处理负数).设置method参数为YeoJohns ...

  10. R语言对dataframe的行数据进行排序(Ordering rows)实战:使用R原生方法、data.table、dplyr等方案

    R语言对dataframe的行数据进行排序(Ordering rows)实战:使用R原生方法.data.table.dplyr等方案 目录

最新文章

  1. 数据挖掘试题(150道) (1)
  2. node-webkit学习(2)基本结构和配置
  3. python菜鸟excel教程-Python菜鸟之路: 封装通用excel操作
  4. swagger使用指南
  5. (二)html5中的属性
  6. 逆向工程核心原理学习笔记(七):总结
  7. 办公自动化-python编写ppt-创建第一页-主标题与内容的编写
  8. MySQL 数据库设计规范
  9. 您未必知道的Css技巧
  10. 长虹CIRI语音智能电视技术原理简析
  11. 计算机表格斜杠怎么打,excel表格斜杠怎么分隔打字(怎么在excel里一个表格内划斜线并添加文字)...
  12. 工作拾忆 一年C++经验小记
  13. https://blog.csdn.net/Darryl_Tang/article/details/80545688
  14. 10.5日饿了么复活了,大家凑合用用吧~(偶尔更新~)
  15. 从事互联网产品运营所需的8条技能
  16. Tomcat学习之路
  17. C++并发实战:面试题2:一道迅雷笔试题
  18. remap中的xmap,ymap详解
  19. 职场新人如何发公司内部邮件
  20. 一个对C#程序混淆加密,小巧但够用的小工具

热门文章

  1. 第二章 列表、表格与媒体元素
  2. 黄仁勋误入直播被当“路人”,英伟达粉丝都乐疯了
  3. 图解二叉树非递归版的前序遍历算法
  4. 忍不了!我辞退了一个学历造假的程序员。。。
  5. element plus 使用v-loading报错解决Can‘t resolve ‘element-plus/es/components/loading-directive/style/index‘
  6. 安装centos7 如何分区
  7. amazon - business 之 references link market
  8. 这个世界上还有一个故事,叫做《大话西游》
  9. 护牙篇丨get纳美宝贝牙膏,让宝宝和蛀牙说拜拜
  10. RNA-seq(2):下载参考基因组及基因注释,及测序数据-学习笔记