《程序设计基础教程 - -C语言版》实验指导手册(2)

2019-04-14 22:01

Manipulator is now used as a industrial robots in use, the control objectives often appear often in industrial automation. Industrial automation technology has gradually matured, as mature a technology line has been rapid development in industrial automation as a separate subject. Manipulator application began to filter into welding, logistics, mechanical processing, and other industries. Especially at high or very low temperatures, full of poisonous gases, high radiation case, robot in similar circumstances showed great use also brings great convenience to the staff. Precisely because of this robot to get people's attention began to be a high degree of development. Labor rates, working conditions, labor intensive aspects of promoting development. Both at home and abroad to develop the PLC (programmable logic controller) is in various special circumstances and under special conditions set for mechanical devices. Now turned on the development of the microelectronics automatic control technology and the rapid development of thetrains, the success of PLC hardware software and simulation control win big and successful development, now continues to develop as a factory automation standards. Because robots are good development of the technology makes a good optimization of productive capital, and robot shows this unique advantages, such as: has good compatibility, wide availability, hardware is complete, and programming that can be mastered in a short time, so in the context of industrial PLC applications became ubiquitous. Manipulator in many developed country agriculture and industry has been applied, such as the use of mechanical harvesting large areas of farmland, repeated operations on the high-speed line that uses a robotic arm, and so on. oday, the high level of automation combined with restrictions on the manipulator development level is slightly lower than the international. The design is mainly arm welding machine by PLC Automation control. This of design let designers on in school by learn of has a must of consolidation, understand has some usually didn't opportunities awareness in world range within some leading level of knowledge has has must awareness, hope designers can in yihou of design in the can success of using in this design in the proceeds of experience 1.2 manipulator in both at home and abroad of research profile automation mechanical arm research began Yu 20th century medium-term, after years with with computer and automation technology of development, Makes mechanical arm on the Grand stage of industrial automation and shine, gradually became an industrial evaluation standards, and its importance can be seen. Now original robotic arm spent most of mass production and use on the production line, which is programmed robotic arm. As the first generation of manipulator position control systems main features, although not back several generations that can detect the external environment, but can still successfully complete like welding, painting, delivery as well as for materials simple movements. Second generation mechanicalarms are equipped with sensors and manipulators have the environment there is a certain amount of \chanical arm is to use the program as a basis. Difference is that the robot begand printf(\ printf(\ printf(\

printf(\ return 0; }

请分析和观察代码有无错误,如果有,有哪些?指出错误原因,并修正之,使其可以按照预想的目的输入相应数据并输出结果;

3. 输入华氏温度的值F,要求输出摄氏温度的取值C,其中,C=5/9*(F-32)。要求输出有文字说明,取两位小数位;

4. 用getchar()函数读入两个字符ch1,ch2,然后分别用putchar()和printf()函数输出这两个字符。试分析思考如下问题:(a) ch1和ch2的数据类型用什么?(b) 要求输出ch1和ch2的ASCII码,应如何处理?是用pringf()还是用putchar()?(c) 整型变量是否在任何情况下都可以相互代替?

5.*请编写和实现教材习题3-15,3-16,3-17和3-18,至少要求实现其中一个问题。 实验准备:

(1) 复习相关内容,阅读并分析1、2、3中的相关程序代码; (2) 对4、5题进行程序代码编写。 实验步骤:

(1) 对照阅读分析结果,上机验证1、2、3的结果,并做出相应分析; (3) 对4、5题进行上机调试,并进行测试、做测试记录; (4) 进行实验分析; (5) 编写实验报告。 实验结果:

(1) 根据测试目标写出测试报告; (2) 测试结果分析说明; (3) 测试程序代码清单。

实验四 分支结构的程序设计(4学时)

实验目的:

(1) 掌握C语言程序设计中逻辑量的表示和运用方法;

(2) 掌握C语言程序设计中条件表达式的值的计算方法及其跟程序执行流程之间的逻辑顺序关系;

(3) 掌握C语言中的4种选择结构语句的执行逻辑及其运用方法。

manipulator control mode and programmable controllers introduction 2.1 Select discussion with manipulator control 2.1.1 classification of control relays and discrete electronic circuit can control old industrial equipment, but also more common. Mainly these two relatively cheap and you can meet the old-fashioned, simple (or simple) industrial equipment. So he can see them now, however these two control modes (relay and discrete electronic circuits) are these fatal flaws: (1) cannot adapt to the complex logic control, (2) only for the current project, the lack of compatibility and (3) not reforming the system with equipment improvements. Spring for the development of China's modern industrial automation technology the substantial increase in the level of industrial automation, completed the perfect relay of the computer too much. In terms of controlling the computer showed his two great advantages: (1) each of the hardware can be installed on one or more microprocessors; (2) the official designer of the software writing content control is all about. Now in several ways in the context of industrial automation can often be seen in three ways: (1) Programmable Logical Controller (referred to as IPC); (2) Distributed Control System (DCS for short), and (3) the Programmable Logical Controller (PLC for short). 2.1.2 PLC and the IPC and DCS contrast contrast 1, each of the three technologies of origins and development requirements for fast data processing makes it invented the computer. The men brought in terms of hardware there, using a high level of standardization, can use more compatibility tools, is a rich software resources, especially the need for immediacy in operational systems. So the computer can effectively control is used to control and meet its speed, on the virtual model, real-time and in computational requirements. Distributed system started with a control system for industrial automatic instrument used to control, whereas now it is successfully developed into industrial control computer used as a central collection and distribution system and transition of distributed control system in analogue handling, loop control, has begun to reflect the use of a huge advantage. Though distributed system has great advantages in loop regulation, but only as a means of continuous process control. Optimization of PLC is the corrsponding relay needs was born, its main use in the work order control, early primary is replaced relay this hulking system, focused on the switch controlling the running order of functions. Marked by the microprocessor in the early 1970 of the 20th century emerged, micro-electronics technology has developed rapidly, people soon microelectronics processing technology will be used in the Programmable Logical Controller (that isManipulator is now used as a industrial robots in use, the control objectives often appear often in industrial automation. Industrial automation technology has gradually matured, as mature a technology line has been rapid development in industrial automation as a separate subject. Manipulator application began to filter into welding, logistics, mechanical processing, and other industries. Especially at high or very low temperatures, full of poisonous gases, high radiation case, robot in similar circumstances showed great use also brings great convenience to the staff. Precisely because of this robot to get people's attention began to be a high degree of development. Labor rates, working conditions, labor intensive aspects of promoting development. Both at home and abroad to develop the PLC (programmable logic controller) is in various special circumstances and under special conditions set for mechanical devices. Now turned on the development of the microelectronics automatic control technology and the rapid development of thetrains, the success of PLC hardware software and simulation control win big and successful development, now continues to develop as a factory automation standards. Because robots are good development of the technology makes a good optimization of productive capital, and robot shows this unique advantages, such as: has good compatibility, wide availability, hardware is complete, and programming that can be mastered in a short time, so in the context of industrial PLC applications became ubiquitous. Manipulator in many developed country agriculture and industry has been applied, such as the use of mechanical harvesting large areas of farmland, repeated operations on the high-speed line that uses a robotic arm, and so on. oday, the high level of automation combined with restrictions on the manipulator development level is slightly lower than the international. The design is mainly arm welding machine by PLC Automation control. This of design let designers on in school by learn of has a must of consolidation, understand has some usually didn't opportunities awareness in world range within some leading level of knowledge has has must awareness, hope designers can in yihou of design in the can success of using in this design in the proceeds of experience 1.2 manipulator in both at home and abroad of research profile automation mechanical arm research began Yu 20th century medium-term, after years with with computer and automation technology of development, Makes mechanical arm on the Grand stage of industrial automation and shine, gradually became an industrial evaluation standards, and its importance can be seen. Now original robotic arm spent most of mass production and use on the production line, which is programmed robotic arm. As the first generation of manipulator position control systems main features, although not back several generations that can detecthe external environment, but can still successfully complete like welding, painting, delivery as well as for materials simple movements. Second generation mechanicalarms are equipped with sensors and manipulators have the environment there is a certain amount of \chanical arm is to use the program as a basis. Difference is that the robot begand实验内容:

1. if 语句的实验。请分析如下语句段的逻辑关系:

int main(void) { ...

if (nA>1 && nB==0) nX=nX/nA; if (nA==2 || nX>1) nX=nX+1; ...

return 0; }

(a) 以算法流程图的形式表述;

(b) 增加输入、输出功能以补充完整该程序段,使之能够运行; (c) 测试该程序段的各种条件组合下的运行结果。测试数据组如下:

nA nB nX 1 1 1 1 1 2 3 0 1 2 0 4 2 1 1 1 0 2 2 1 2 3 0 2 (d) 分析讨论:

1) 用哪组数据就可以使程序段中每个处理语句都执行一次?为了找出程序中的逻辑错误,应使用什么样的数据进行测试?请上机验证自己的分析结果。

2) 用哪两组数据可以使程序段中的每个分支都至少运行一次?为找出各个分支中的逻辑错误,应选用什么样的数据进行逻辑测试?请上机验证自己的分析结果。

3) 用哪四组数据可以将从起点到终点的各条路径都覆盖一次?为了测试程序在各个不同路径上的错误,应选用什么样的测试数据?请上机验证自己的分析结果。

2. if else语句实验。用if else句型,编写求4个数中最大者的程序,并设计测试用例、记录测试结果;

3. 试用if else if else if ...else实现求4个数中最大者的程序,并做相应测试; 4. 试用switch语句句型实现以上程序,并做相应测试; 5. 请理清习题5-23的逻辑关系,上机进行验证。 实验准备:

manipulator control mode and programmable controllers introduction 2.1 Select discussion with manipulator control 2.1.1 classification of control relays and discrete electronic circuit can control old industrial equipment, but also more common. Mainly these two relatively cheap and you can meet the old-fashioned, simple (or simple) industrial equipment. So he can see them now, however these two control modes (relay and discrete electronic circuits) are these fatal flaws: (1) cannot adapt to the complex logic control, (2) only for the current project, the lack of compatibility and (3) not reforming the system with equipment improvements. Spring for the development of China's modern industrial automation technology the substantial increase in the level of industrial automation, completed the perfect relay of the computer too much. In terms of controlling the computer showed his two great advantages: (1) each of the hardware can be installed on one or more microprocessors; (2) the official designer of the software writing content control is all about. Now in several ways in the context of industrial automation can often be seen in three ways: (1) Programmable Logical Controller (referred to as IPC); (2) Distributed Control System (DCS for short), and (3) the Programmable Logical Controller (PLC for short). 2.1.2 PLC and the IPC and DCS contrast contrast 1, each of the three technologies of origins and development requirements for fast data processing makes it invented the computer. The men brought in terms of hardware there, using a high level of standardization, can use more compatibility tools, is a rich software resources, especially the need for immediacy in operational systems. So the computer can effectively control is used to control and meet its speed, on the virtual model, real-time and in computational requirements. Distributed system started with a control system for industrial automatic instrument used to control, whereas now it is successfully developed into industrial control computer used as a central collection and distribution system and transition of distributed control system in analogue handling, loop control, has begun to reflect the use of a huge advantage. Though distributed system has great advantages in loop regulation, but only as a means of continuous process control. Optimization of PLC is the corresponding relay needs was born, its main use in the work order control, early primary is replaced relay this hulking system, focused on the switch controlling the running order of functions. Marked by the microprocessor in the early 1970 of the 20th century emerged, micro-electronics technology has developed rapidly, people soon microelectronics processing technology will be used in the Programmable Logical Controller (that isManipulator is now used as a industrial robots in use, the control objectives often appear often in industrial automation. Industrial automation technology has gradually matured, as mature a technology line has been rapid development in industrial automation as a separate subject. Manipulator application began to filter into welding, logistics, mechanical processing, and other industries. Especially at high or very low temperatures, full of poisonous gases, high radiation case, robot in similar circumstances showed great use also brings great convenience to the staff. Precisely because of this robot to get people's attention began to be a high degree of development. Labor rates, working conditions, labor intensive aspects of promoting development. Both at home and abroad to develop the PLC (programmable logic controller) is in various special circumstances and under special conditions set for mechanical devices. Now turned on the development of the microelectronics automatic control technology and the rapid development of thetrains, the success of PLC hardware software and simulation control win big and successful development, now continues to develop as a factory automation standards. Because robots are good development of the technology makes a good optimization of productive capital, and robot shows this unique advantages, such as: has good compatibility, wide availability, hardware is complete, and programming that can be mastered in a short time, so in the context of industrial PLC applications became ubiquitous. Manipulator in many developed country agriculture and industry has been applied, such as the use of mechanical harvesting large areas of farmland, repeated operations on the high-speed line that uses a robotic arm, and so on. oday, the high level of automation combined with restrictions on the manipulator development level is slightly lower than the international. The design is mainly arm welding machine by PLC Automation control. This of design let designers on in school by learn of has a must of consolidation, understand has some usually didn't opportunities awareness in world range within some leading level of knowledge has has must awareness, hope designers can in yihou of design in the can success of using in this design in the proceeds of experience 1.2 manipulator in both at home and abroad of research profile automation mechanical arm research began Yu 20th century medium-term, after years with with computer and automation technology of development, Makes mechanical arm on the Grand stage of industrial automation and shine, gradually became an industrial evaluation standards, and its importance can be seen. Now original robotic arm spent most of mass production and use on the production line, which is programmed robotic arm. As the first generation of manipulator position control systems main features, although not back several generations that can detect the external environment, but can still successfully complete like welding, painting, delivery as well as for materials simple movements. Second generation mechanicalarms are equipped with sensors and manipulators have the environment there is a certain amount of \chanical arm is to use the program as a basis. Difference is that the robot begand (1) 阅读并分析第1题中的逻辑关系及其分支测试方法; (2) 分析并编写2、3、4题(需要绘制流程图)的程序代码。 实验步骤:

(1) 对照阅读分析结果,上机验证1题的测试结果,并做出相应分析; (2) 上机运行和测试所写的2、3、4、5题程序代码; (3) 进行实验分析; (4) 编写实验报告。 实验结果:

(1) 根据测试目标写出测试报告; (2) 测试结果分析说明; (3) 测试程序代码清单。

实验五 循环控制程序的设计(4学时)

实验目的:

(1) 复习和掌握算法的基本组成要素和描述特点;

(2) 在实验四的基础上,学习几种常见的循环程序的流程关系和运用方法; (3) 不同循环类型之间的转换方法; (4) 循环的应用。

实验内容:(1和2必做,3和4选做)

1.循环实验(教材习题5-20)。具体要求:

(1) 绘制流程图,编制程序代码。

(2) 分析不进入循环、只循环一次、只循环两次、进入死循环的条件,以及

此时各变量的值。

(3) 分析循环退出时的条件表达式值。 (4) 如何测试循环的次数?

(5) 能否将程序改写成另外的形式,如while改写成do while或for语句? (6) 总结条件循环的设计、实现步骤和测试方法。

2.计数型循环实验(教材习题5-30):九九表及其变体形状的打印。具体要求如下:

(1) 分析并绘制九九表的程序实现代码(右上三角形状); (2) 分析程序的执行过程;

(3)* 请在此基础上修改部分程序代码以打印如下一些变形九九表:右下三

角、左上三角、左下三角、倒序排列等形状,并观察、分析和总结其规律。 (4) 分析并总结计数型循环在do while, while和for循环句型中的实现方法

manipulator control mode and programmable controllers introduction 2.1 Select discussion with manipulator control 2.1.1 classification of control relays and discrete electronic circuit can control old industrial equipment, but also more common. Mainly these two relatively cheap and you can meet the old-fashioned, simple (or simple) industrial equipment. So he can see them now, however these two control modes (relay and discrete electronic circuits) are these fatal flaws: (1) cannot adapt to the complex logic control, (2) only for the current project, the lack of compatibility and (3) not reforming the system with equipment improvements. Spring for the development of China's modern industrial automation technology the substantial increase in the level of industrial automation, completed the perfect relay of the computer too much. In terms of controlling the computer showed his two great advantages: (1) each of the hardware can be installed on one or more microprocessors; (2) the official designer of the software writing content control is all about. Now in several ways in the context of industrial automation can often be seen in three ways: (1) Programmable Logical Controller (referred to as IPC); (2) Distributed Control System (DCS for short), and (3) the Programmable Logical Controller (PLC for short). 2.1.2 PLC and the IPC and DCS contrast contrast 1, each of the three technologies of origins and development requirements for fast data processing makes it invented the computer. The men brought in terms of hardware there, using a high level of standardization, can use more compatibility tools, is a rich software resources, especially the need for immediacy in operational systems. So the computer can effectively control is used to control and meet its speed, on the virtual model, real-time and in computational requirements. Distributed system started with a control system for industrial automatic instrument used to control, whereas now it is successfully developed into industrial control computer used as a central collection and distribution system and transition of distributed control system in analogue handling, loop control, has begun to reflect the use of a huge advantage. Though distributed system has great advantages in loop regulation, but only as a means of continuous process control. Optimization of PLC is the corrsponding relay needs was born, its main use in the work order control, early primary is replaced relay this hulking system, focused on the switch controlling the running order of functions. Marked by the microprocessor in the early 1970 of the 20th century emerged, micro-electronics technology has developed rapidly, people soon microelectronics processing technology will be used in the Programmable Logical Controller (that isManipulator is now used as a industrial robots in use, the control objectives often appear often in industrial automation. Industrial automation technology has gradually matured, as mature a technology line has been rapid development in industrial automation as a separate subject. Manipulator application began to filter into welding, logistics, mechanical processing, and other industries. Especially at high or very low temperatures, full of poisonous gases, high radiation case, robot in similar circumstances showed great use also brings great convenience to the staff. Precisely because of this robot to get people's attention began to be a high degree of development. Labor rates, working conditions, labor intensive aspects of promoting development. Both at home and abroad to develop the PLC (programmable logic controller) is in various special circumstances and under special conditions set for mechanical devices. Now turned on the development of the microelectronics automatic control technology and the rapid development of thetrains, the success of PLC hardware software and simulation control win big and successful development, now continues to develop as a factory automation standards. Because robots are good development of the technology makes a good optimization of productive capital, and robot shows this unique advantages, such as: has good compatibility, wide availability, hardware is complete, and programming that can be mastered in a short time, so in the context of industrial PLC applications became ubiquitous. Manipulator in many developed country agriculture and industry has been applied, such as the use of mechanical harvesting large areas of farmland, repeated operations on the high-speed line that uses a robotic arm, and so on. oday, the high level of automation combined with restrictions on the manipulator development level is slightly lower than the international. The design is mainly arm welding machine by PLC Automation control. This of design let designers on in school by learn of has a must of consolidation, understand has some usually didn't opportunities awareness in world range within some leading level of knowledge has has must awareness, hope designers can in yihou of design in the can success of using in this design in the proceeds of experience 1.2 manipulator in both at home and abroad of research profile automation mechanical arm research began Yu 20th century medium-term, after years with with computer and automation technology of development, Makes mechanical arm on the Grand stage of industrial automation and shine, gradually became an industrial evaluation standards, and its importance can be seen. Now original robotic arm spent most of mass production and use on the production line, which is programmed robotic arm. As the first generation of manipulator position control systems main features, although not back several generations that can detecthe external environment, but can still successfully complete like welding, painting, delivery as well as for materials simple movements. Second generation mechanicalarms are equipped with sensors and manipulators have the environment there is a certain amount of \chanical arm is to use the program as a basis. Difference is that the robot begand和步骤。

3.其它实验题目:

(1) 习题5-1(小孩吃梨问题); (2) 习题5-4(水果拼盘问题);

(3) 求两个非负整数u和v的最大公因子; (4) 求两个非负整数的最小公约数; (5) 用牛顿迭代法求解正实数a的平方根; (6) 用梯形法求函数的数值积分;

(7) 把由键盘输入的数列(1,3,5,7,9...)按相反的顺序(如...9,7,5,3,1)输出。

4.习题5-27和习题5-28。

实验准备:

(1) 编写所选实验题目的程序代码和流程图; (2) 检查源程序并给出其可能的运行结果说明。 实验步骤:

(1) 上机验证所选题目,并做相应测试和分析; (2) 进行实验分析;

(3) 总结循环程序设计、实现本方法及其经验; (4) 编写实验报告。 实验结果:

(1) 根据测试目标写出测试报告; (2) 测试结果分析说明; (3) 测试程序代码清单。

实验六 基于函数的模块化程序设计(4学时)

实验目的:

(1) 了解和掌握C语言环境下模块化程序设计的基础----基于函数模块的程序设计技术;

(2) 复习C语言程序的基本结构特点,了解基于函数模块的程序模块及其调用关系、过程;

(3) 函数的声明、定义、使用方法; (4) 对各种变量属性的使用方法;

(5) 对C语言中常用的预编译语句的基本掌握。

manipulator control mode and programmable controllers introduction 2.1 Select discussion with manipulator control 2.1.1 classification of control relays and discrete electronic circuit can control old industrial equipment, but also more common. Mainly these two relatively cheap and you can meet the old-fashioned, simple (or simple) industrial equipment. So he can see them now, however these two control modes (relay and discrete electronic circuits) are these fatal flaws: (1) cannot adapt to the complex logic control, (2) only for the current project, the lack of compatibility and (3) not reforming the system with equipment improvements. Spring for the development of China's modern industrial automation technology the substantial increase in the level of industrial automation, completed the perfect relay of the computer too much. In terms of controlling the computer showed his two great advantages: (1) each of the hardware can be installed on one or more microprocessors; (2) the official designer of the software writing content control is all about. Now in several ways in the context of industrial automation can often be seen in three ways: (1) Programmable Logical Controller (referred to as IPC); (2) Distributed Control System (DCS for short), and (3) the Programmable Logical Controller (PLC for short). 2.1.2 PLC and the IPC and DCS contrast contrast 1, each of the three technologies of origins and development requirements for fast data processing makes it invented the computer. The men brought in terms of hardware there, using a high level of standardization, can use more compatibility tools, is a rich software resources, especially the need for immediacy in operational systems. So the computer can effectively control is used to control and meet its speed, on the virtual model, real-time and in computational requirements. Distributed system started with a control system for industrial automatic instrument used to control, whereas now it is successfully developed into industrial control computer used as a central collection and distribution system and transition of distributed control system in analogue handling, loop control, has begun to reflect the use of a huge advantage. Though distributed system has great advantages in loop regulation, but only as a means of continuous process control. Optimization of PLC is the corresponding relay needs was born, its main use in the work order control, early primary is replaced relay this hulking system, focused on the switch controlling the running order of functions. Marked by the microprocessor in the early 1970 of the 20th century emerged, micro-electronics technology has developed rapidly, people soon microelectronics processing technology will be used in the Programmable Logical Controller (that isManipulator is now used as a industrial robots in use, the control objectives often appear often in industrial automation. Industrial automation technology has gradually matured, as mature a technology line has been rapid development in industrial automation as a separate subject. Manipulator application began to filter into welding, logistics, mechanical processing, and other industries. Especially at high or very low temperatures, full of poisonous gases, high radiation case, robot in similar circumstances showed great use also brings great convenience to the staff. Precisely because of this robot to get people's attention began to be a high degree of development. Labor rates, working conditions, labor intensive aspects of promoting development. Both at home and abroad to develop the PLC (programmable logic controller) is in various special circumstances and under special conditions set for mechanical devices. Now turned on the development of the microelectronics automatic control technology and the rapid development of thetrains, the success of PLC hardware software and simulation control win big and successful development, now continues to develop as a factory automation standards. Because robots are good development of the technology makes a good optimization of productive capital, and robot shows this unique advantages, such as: has good compatibility, wide availability, hardware is complete, and programming that can be mastered in a short time, so in the context of industrial PLC applications became ubiquitous. Manipulator in many developed country agriculture and industry has been applied, such as the use of mechanical harvesting large areas of farmland, repeated operations on the high-speed line that uses a robotic arm, and so on. oday, the high level of automation combined with restrictions on the manipulator development level is slightly lower than the international. The design is mainly arm welding machine by PLC Automation control. This of design let designers on in school by learn of has a must of consolidation, understand has some usually didn't opportunities awareness in world range within some leading level of knowledge has has must awareness, hope designers can in yihou of design in the can success of using in this design in the proceeds of experience 1.2 manipulator in both at home and abroad of research profile automation mechanical arm research began Yu 20th century medium-term, after years with with computer and automation technology of development, Makes mechanical arm on the Grand stage of industrial automation and shine, gradually became an industrial evaluation standards, and its importance can be seen. Now original robotic arm spent most of mass production and use on the production line, which is programmed robotic arm. As the first generation of manipulator position control systems main features, although not back several generations that can detect the external environment, but can still successfully complete like welding, painting, delivery as well as for materials simple movements. Second generation mechanicalarms are equipped with sensors and manipulators have the environment there is a certain amount of \chanical arm is to use the program as a basis. Difference is that the robot begand 实验内容:(第1题任选其两个小题,第2题和第3题必做)

1.函数的声明、定义和使用方法。具体实例如下: (1) 编写一个在屏幕上画一条正弦曲线的函数;

(2) 编写一个函数,它可以求出给定数的所有因子,如下形式显示其结果:72=2*2*2*3*3;

(3) 分别写出一个求N个数的最大公约数和最小公倍数的递归函数; (4) 试编制n碟片hanoi塔的问题求解函数,并利用它求解4个盘片的结果; (5) 试编写求n!的函数,并求n=7的结果。 具体要求如下:

(1) 编写程序通过调试获得正确结果; (2) 分析函数的声明、定义和使用方法; (3) 分别分析函数调用时的参数传值调用方法。

2.有关变量的属性实验(静态、动态、全局、局部等方面)。具体实例如下: (1) 仔细分析以下程序的执行结果,然后上机运行如下程序段,并对各个变量的属性及其使用结果进行比较分析:

int main(void)

{ /******(a)******/ int nX=1;

{/******(b)******/ void prt(void); int nX=3; prt();

printf(\ }/******(c)******/

printf(\ return 0; }

void prt(void)

{ /******(d)******/ int nX=5;

printf(\ }/******(e)******/

(2) 仔细分析下列程序,是否有错误之处?然后分析其执行结果,上机验证并对各个变量的存储属性及其结果进行比较分析:

#define LOW 11 #define HIGH 23 #define CHANGE 12 int i=LOW; int main(void)

manipulator control mode and programmable controllers introduction 2.1 Select discussion with manipulator control 2.1.1 classification of control relays and discrete electronic circuit can control old industrial equipment, but also more common. Mainly these two relatively cheap and you can meet the old-fashioned, simple (or simple) industrial equipment. So he can see them now, however these two control modes (relay and discrete electronic circuits) are these fatal flaws: (1) cannot adapt to the complex logic control, (2) only for the current project, the lack of compatibility and (3) not reforming the system with equipment improvements. Spring for the development of China's modern industrial automation technology the substantial increase in the level of industrial automation, completed the perfect relay of the computer too much. In terms of controlling the computer showed his two great advantages: (1) each of the hardware can be installed on one or more microprocessors; (2) the official designer of the software writing content control is all about. Now in several ways in the context of industrial automation can often be seen in three ways: (1) Programmable Logical Controller (referred to as IPC); (2) Distributed Control System (DCS for short), and (3) the Programmable Logical Controller (PLC for short). 2.1.2 PLC and the IPC and DCS contrast contrast 1, each of the three technologies of origins and development requirements for fast data processing makes it invented the computer. The men brought in terms of hardware there, using a high level of standardization, can use more compatibility tools, is a rich software resources, especially the need for immediacy in operational systems. So the computer can effectively control is used to control and meet its speed, on the virtual model, real-time and in computational requirements. Distributed system started with a control system for industrial automatic instrument used to control, whereas now it is successfully developed into industrial control computer used as a central collection and distribution system and transition of distributed control system in analogue handling, loop control, has begun to reflect the use of a huge advantage. Though distributed system has great advantages in loop regulation, but only as a means of continuous process control. Optimization of PLC is the corrsponding relay needs was born, its main use in the work order control, early primary is replaced relay this hulking system, focused on the switch controlling the running order of functions. Marked by the microprocessor in the early 1970 of the 20th century emerged, micro-electronics technology has developed rapidly, people soon microelectronics processing technology will be used in the Programmable Logical Controller (that is


《程序设计基础教程 - -C语言版》实验指导手册(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:离婚房产分割律师实务策略

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: