南京航空航天大学:《C++程序设计》课程教学资源(PPT课件)第1章 C++程序设计基础(主讲:陈哲)

1954 FORTRAN ALGOL COBOL PLI 程序设 Imperative 1967 1968 0G0 计语言 Functional 1969 1970 ASCAL 的发展 Procedural 1971 SMALLTALK 历史 Object orien 1975 SCHEME Object based 1980 COMMO 1985 Object oriented 1987 HASKEL 1988(cL0s
程序设 计语言 的发展 历史

为什么要学习C++程序设计 1.C++是C的扩充版本。C++对C的扩充是由 Bjarne stroustrup于1980年在贝尔实验室提 出来的。起初他把这种语言称为“带类的C”, 到1983年才改名为C++。 2.C++吸收了C和 simula67的精髓,它具有C所 无法比拟的优越性
3 为什么要学习C++程序设计 1. C++是C的扩充版本。C++对C的扩充是由 Bjarne Stroustrup于1980年在贝尔实验室提 出来的。起初他把这种语言称为“带类的C”, 到1983年才改名为C++。 2. C++吸收了C和Simula67的精髓,它具有C所 无法比拟的优越性

13简单的输入与输出方法 #include using namespace std; int main( int a. bs ∥定义2个变量 cout>a>>b;/从键盘输入a和b的值* cout <<a+b=w<<a+b<< endl return O 见1-1cpp
4 1.3 简单的输入与输出方法 #include using namespace std; int main ( ) { int a, b; // 定义2个变量 cout > a >> b; /* 从键盘输入a和b的值*/ cout << "a + b = " << a + b << endl; return 0; } 见1-1.cpp

14标识符 标识符由字母、下划线和数字组成,且第一个字 符不能为数字,长度一般不超过32个,文件名只 识别前8个字符。标识符大小写敏感。 · studentName、 Studentname、 name of student abc、a123 ·8abc、 Student name、 Sbill 命名原则:要尽可能做到“见名知意”,选择有 含义的单词符号作标识符,使别人(包括你本人) 容易读懂你的程序
5 1.4 标识符 • 标识符由字母、下划线和数字组成,且第一个字 符不能为数字,长度一般不超过32个,文件名只 识别前8个字符。标识符大小写敏感。 • studentName、StudentName、name_of_student • abc、a123 • 8abc 、Student Name、$bill • 命名原则:要尽可能做到“见名知意”,选择有 含义的单词符号作标识符,使别人(包括你本人) 容易读懂你的程序

1.5布尔类型 布尔数据:1值为true,0值为 false 【例1-7】布尔变量的输入和输出。 #include using namespace std: int main() bool bvalue b Value= true ∥rue实际上就是数值1 cout < bvalue<< bvalue= false;∥ false实际上就是数值0 cout < bValue < end 见1-7cpp return 0:
6 1.5 布尔类型 布尔数据:1值为true,0值为false。 【例1-7】布尔变量的输入和输出。 #include using namespace std; int main( ) { bool bValue ; bValue = true ; // true实际上就是数值1 cout << bValue << " " ; bValue = false ; // false实际上就是数值0 cout << bValue << endl ; return 0; } 见1-7.cpp

16良好的编程风格 程序员使用标识符、空格、Tab键、空行、 标点符号、代码缩进排列和注释等,来安 排源代码的方式。 【例1-8】一个不好的风格程序 #include using namespace std; int main({inta,b;cout>a>> b cout <<a+b=<<a+ b<< endl; return 0;)
7 1.6 良好的编程风格 • 程序员使用标识符、空格、Tab键、空行、 标点符号、代码缩进排列和注释等,来安 排源代码的方式。 【例1-8】一个不好的风格程序 #include using namespace std; int main ( ){int a, b; cout > a >> b; cout << "a + b = " << a + b << endl; return 0; }

注释方法 1.C++的注释形式有两种,一种是“/*”格式, 这是C语言中的注释风格; 2双斜线/,在双斜线之后的部分都会被视为注释; 不必为程序的每一行都加注释,也不必为一目了 然的代码加注释,只要注解适当的代码,有助于 他人理解即可
8 注释方法 1. C++的注释形式有两种,一种是“/* */”格式, 这是C语言中的注释风格 ; 2.双斜线//,在双斜线之后的部分都会被视为注释; 不必为程序的每一行都加注释,也不必为一目了 然的代码加注释,只要注解适当的代码,有助于 他人理解即可

kk☆kkkk☆:☆κk☆:k☆κkκk:κ☆κκκκκκκκκκκκκκκκκκκ ∥作者:张 ∥功能:计算XXX公司的员工的工资 ∥最后修改时间:2012年12月3日 kkkk;kkk☆kk;k☆k;kk☆k☆k☆k☆κk☆k☆k☆:k;k☆;kk六 #include using namespace std int main() float pay Rate i ∥存储单位小时内的工资 float hours ∥存储员工已经工作的小时数 int empNum ∥存储工号
//**************************************************** // 作 者:张 三 // 功 能:计算XXX公司的员工的工资 // 最后修改时间:2012年12月3日 //**************************************************** #include using namespace std; int main( ) { float payRate ; // 存储单位小时内的工资 float hours ; // 存储员工已经工作的小时数 int empNum ; // 存储工号 …… }

17格式化输出 °cout/cin:输出/流对象; 例如:cout”流提取操作符 【例19】程序举例
10 1.7 格式化输出 • cout/cin:输出/入流对象; 例如: cout >” 流提取操作符 • 【例1.9】程序举例

#include using namespace std: int main( fint numl=2897, num2=5, num=837, num4=34,num5=7,num6=1623, num7=390,num8=3456,num9=12; 显示第一行数 cout<<mum1<<"";∥muml后面空了3个空格 cout<< num2<< cout < num << endl ∥显示第二行数 cout<< numa<< cout < num cout << numb<< endl ∥显示第三行数 cout < num7 cout < num8<< cout << num << endl return 0 见1-9cpp
#include using namespace std; int main( ) { int num1 = 2897, num2 = 5, num3 = 837, num4 = 34, num5 = 7, num6 = 1623, num7 = 390, num8 = 3456, num9 = 12 ; // 显示第一行数 cout << num1 << " " ; // num1后面空了3个空格 cout << num2 << " " ; cout << num3 << endl ; // 显示第二行数 cout << num4 << " " ; cout << num5 << " " ; cout << num6 << endl ; // 显示第三行数 cout << num7 << " " ; cout << num8 <<" " ; cout << num9 << endl ; return 0; } 见1-9.cpp
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《Excel实用技术基础》课程教学资源(PPT课件讲稿)Excel 技术基础、数据管理.ppt
- 《计算机系统》课程教学资源(PPT课件讲稿)第六章 设备管理 Devices Management.ppt
- Introduction to XML IR(PPT讲稿).ppt
- 中国传媒大学(北京广播学院):《计算机网络》课程教学资源(PPT课件讲稿)第五章 网络层 The Network Layer.ppt
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第六章 中断(主讲:刘忠国).ppt
- 《工程计算软件》课程教学资源(PPT课件讲稿)第四章 Maple简介.ppt
- 中国科学技术大学:QuickPass系统的排队问题(PPT讲座,谢瑶).ppt
- 中国科学技术大学:《网络信息安全 NETWORK SECURITY》课程教学资源(PPT课件讲稿)第十章 入侵检测系统(主讲:肖明军).ppt
- 东南大学:《数据结构》课程教学资源(PPT课件讲稿)第五章 树(主讲:方效林).ppt
- 西南民族大学:《软件需求分析与总体设计》课程教学资源(PPT课件讲稿)软件总体(概要)设计.ppt
- 北京航空航天大学:Graph Search - a New Paradigm for Social Computing.pptx
- 清华大学:《计算机网络》课程教学资源(PPT课件讲稿)Lecture 4 Routing.pptx
- Homomorphic Secret Sharing:Low-End HSS from OWF、HSS for Branching Programs from DDH、The HSS Construction.ppsx
- 四川大学:软件设计工具(PPT课件讲稿)Software design tool.ppt
- 《图像处理与计算机视觉 Image Processing and Computer Vision》课程教学资源(PPT课件讲稿)Chapter 02 Image processing and computer vision(Camera models and parameters).pptx
- 《数据结构》课程教学资源(PPT课件讲稿)第九章 排序.ppt
- 福建工程学院:《软件工程》课程教学资源(实验指导书).doc
- 香港中文大学:Adaboost for building robust classifiers(PPT讲稿).pptx
- 《软件测试》课程教学资源(PPT讲稿)集成测试.pptx
- 《大学计算机基础》课程教学资源(PPT课件讲稿)第三章 字处理软件 Word2003.ppt
- 《计算机组成原理》课程教学资源(PPT课件讲稿)第6章 总线结构.ppt
- 四川大学:Object-Oriented Design and Programming(Java,PPT课件)Advanced Class Design.ppt
- 香港科技大学:Latent Tree Models Part III:Learning Algorithms.pptx
- 《多媒体教学软件设计》课程教学资源(PPT课件讲稿)第3章 多媒体教学软件开发平台(Authorware).ppt
- 河南中医药大学(河南中医学院):《网络技术实训》课程教学资源(PPT课件讲稿)第9讲 通过VPN访问企业网内部服务器设计讨论.pptx
- 四川大学:《操作系统 Operating System》课程教学资源(PPT课件讲稿)Chapter 2 Operating System Overview.ppt
- 《数据结构 Data Structure》课程教学资源(PPT课件讲稿)第三章 栈和队列.ppt
- IS6000 – Seminar 8 Research Methods – Case Study – Action Research.pptx
- 《编译原理》课程教学资源(PPT课件讲稿)上下文无关文法——自顶向下分析.pptx
- 《计算机应用基础》课程教学资源(PPT讲稿)统考考前辅导.ppt
- Cassandra and Sigmod contest.pptx
- 上海交通大学:《数字图像处理 Digital Image Processing》课程教学资源(PPT课件讲稿,第三版)Chapter 9 Morphological Image Processing.pptx
- 南京航空航天大学:《模式识别》课程教学资源(PPT讲稿)Model Selection for SVM & Our intent works.ppt
- 中国科学技术大学:《微机原理》课程教学资源(PPT课件讲稿)第八章 中断系统.pptx
- 《单片机原理及应用》课程教学资源(PPT课件讲稿)第3章 MCS-51单片机的指令系统.pptx
- 合肥工业大学:《网络安全概论》课程教学资源(PPT课件讲稿)无线网络安全.ppt
- 《计算机辅助设计——CAD制图》课程标准.pdf
- 《Link Layer Computer Networking:A Top Down Approach》课程教学资源(PPT课件讲稿)Chapter 5 The Data Link Layer.ppt
- 《计算机网络》课程教学资源(PPT课件讲稿)Chapter 06 广域网技术.ppt
- 《电脑组装与维护实例教程》教学资源(PPT课件讲稿)第13章 计算机的保养.ppt