c++教案资料

上传人:E**** 文档编号:102048328 上传时间:2019-10-01 格式:DOC 页数:116 大小:840KB
返回 下载 相关 举报
c++教案资料_第1页
第1页 / 共116页
c++教案资料_第2页
第2页 / 共116页
c++教案资料_第3页
第3页 / 共116页
c++教案资料_第4页
第4页 / 共116页
c++教案资料_第5页
第5页 / 共116页
点击查看更多>>
资源描述

《c++教案资料》由会员分享,可在线阅读,更多相关《c++教案资料(116页珍藏版)》请在金锄头文库上搜索。

1、成绩评定方式:期末闭卷考试:70%平时成绩:30%平时成绩的组成:22分 ,扣分项目,上课或实验缺席 1次3分,迟到 1分,不交作业1次扣3分,不做课内实验,不提交课内实验报告扣12分,严禁抄袭,发现扣12分8分,加分项目,完成老师布置的课后实验或用C+独立完成有一定规模的程序12 大体和C的内容差不多,比较简单,主要是复习。1,2章 C+ 简介 C+基础1 入门1.1 程序的开发过程 阶段? 编程工具? 复习:小和尚程序?求pi, pi=16arctan(1/5)-4arctan(1/239),arctan(x)=x-x3/3+x5/5-x7/7+1.2 简单程序的C和C+的比较1. fir

2、st: hello worldfirst C+first CCan you see the meaning of every word? What do you think the difference of C and C plus? 2. a example of C plus with classBasketballPlayer.cppDo you know the program?From the example, do you think the C+ is better than C? Try performing the aim by C?用结构化的方法,BasketballPl

3、ayer。推荐开发工具,学习方法和参考资料网络,电子书,看程序,写程序,msdn,论坛初级:C+语言程序设计教程 DeitelC+程序设计语言 Stroustrup中级:C+编程思想 EckelC+语言设计与演化 Stroustrup数据结构、算法与应用:C+语言描述 Sahni高级:C+核心:软件工程方法 Shtern大型C+软件设计 Lakos作业:第一章课后作业,阅读第一章预习第二章2 C +中的C2.1 C+的产生orient procedure , orient objectwho founded the C +? Bjarne Stroustrup2.2部分语法元素c+2.ppt

4、1. 关键字 2. 标示符:变量,对象,函数,类的名字,注意命名标示符规则3. 基本数据类型:注意各个数据类型的表示范围CharType.cppWhat result of the program? Why?4. 常量整型:十进制,八进制,十六进制实型:一般形式,指数形式(科学计数),后缀字符型:单引号 A, & 7注意 不可见字符?转义字符:用八进制,十六进制ASCII码来表示字符 /456 /x61一些预定义的字符常量:a, n, t, r 字符串: “hello world” 注意:“A”和A的区别布尔常量: true false注意常量的各种写法5. 变量变量的声明:声明的形式 类型

5、名字 初始值 int a=3; int b(5);注意:使用之前必须声明6. 符号常量给常量取个名字。Why? The aim?How? Const float pi=3.14;注意:在声明时一定要赋初值7. 运算符与算术表达式参考PPTa) 算术b) 赋值c) 逗号d) 逻辑e) 条件:唯一的三元运算符 (ab):a,b;f) sizeof: 用于计算某种类型的对象在内存中的字节数g) 位:与 或 异或 移位 取反注意:运算符的优先级8. 表达式中数据类型的转换隐含转换:降低的转成高的显示转换:方法 int(a) , (int)a ;2.3 C+ 中的输入输出方法 cout cincouta

6、; cinab;简单的格式控制 ends endl “n”输出十六进制?hex oct dec设置精度?宽度? Setprecision setw注意:头文件 iomanip2.4 程序结构顺序 选择 循环程序流程图? 符号 作用1. 选择结构IsLeap.cppSwitch.cppWhat function of switch? Trying modify the program, make it run more times.Write a program to decide your body? Height weight2. 循环结构while for do-while while S

7、umofN.cppInversNumber.cppCan you solve the problem with while word?DoWhileSum.cpp For Factors.cppOutputFig.cppStaNumber.cpp3. 其他有用的控制语句 break continue goto 2.5 自定义数据类型1. typedef:用于将已有的类型取个新的名字。What?How : typedef int natural; natural i1,i2;2. 枚举 enumwhat: 将需要的变量值一一列出来,枚举变量只能取列表中的值how:enum weekday sun

8、,mon,tue,wed,thu,fri,sat;enum.cppConclusion it is a list of some related constsAttention: type trans must be do when give a enum variant to a int variant 3. 结构体what: combing different data type to a entry.How:Sturct.cppWeight.cppModify the program to evaluate your body after class?4. 联合体what:same as

9、 struct, but diffenrence ? share same space.How:Union.cpp作业:练习题:3大体和C的内容差不多,主要是复习,同时强调C+中不一样的地方。3章 函数what function? What aim?Can you give a example with function?3.1有关函数的术语定义声明调用npower.cppcan you see every part of a function?Do you think what should be cared when define and use a function?3.2 函数举例和函

10、数的作用BittoDec.cppDo you think functions is useful?calculatepi.cppWhat feel do you with this?Algorithm is more important than language?Some techniques in practice?Symm.cppMathformula.cppCan you tell me the mean of using function?Decompose a big problem into several little modulesImprove the readabilit

11、y of programsMaking complexity to simplenessWrite a function to evaluate your body after class?Game.cppAfter class:写一个和计算机玩石头 剪刀 布的程序。统计100局的胜负比例?Conclusion:Functions is very very very important, it is the base of large programs!But how to design some functions to solve a problem is not a simple wor

12、k, it need your experiments and techniques, so you should practice more!3.3 函数的嵌套和递归调用1. 函数调用的执行过程调用返回2. 嵌套调用函数中又调用其他函数3_7.cpp3. 递归调用函数中又调用自己why? 现实中有些问题具有递归性,用递归调用解决非常简单明。Fac.cpp注意:递归函数中必须要有退出的条件comm.cpphow fell with recursion?The ability of analyze is more important than language?Conclusion:Recurs

13、ion is a very power tool for some problems.习题After class:Read Hanoi.cpp 汉诺塔问题3.4 函数的参数传递1. 有关参数的术语Swape.cpp 形参 实参不改变实参的调用,传值调用Swape.cpp改变实参的调用,传地址调用引用:变量的别名what? 参数传递how? Int &a=b;Swapref.cpp注意:使用引用时应注意的问题:初始化引用不能改为指向其他对象after class:If no ref, how to imply the address call? Write a program?How feel

14、to ref?Conclusion:Ref is a good thing?3_13.cpp3.5 内联函数inline和普通函数的区别:编译时在调用处用函数体进行替换,节省了参数传递、控制转移等开销inline.cpp3.6 默认形参值what? To more simple函数在声明时可以预先给出默认的形参值,调用时如给出实参,则采用实参值,否则采用预先给出的默认形参值。C+3.PPT注意: 默认形参值必须从右向左顺序声明,并且在默认形参值的右面不能有非默认形参值的参数。 调用出现在函数体实现之前时,默认形参值必须在函数原形中给出;而当调用出现在函数体实现之后时,默认形参值需在函数实现时给出。Defultparameter.cppThinking: what should be careful to default parameter?3.7 函数重载在C中,两个函数可以有相同的名字吗?C+ 中,允许?Reload.cpp注意:编译器怎样区别两个同名函数?重载的函数必须有去区别? 用什么来区别?形参的 数量 和 类型 thinking:what aim of reload function? To clear program?3

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号