1 / 21

复 习

复 习. 第 3 章 基本数据类型、运算符与表达式. 掌握基本数据类型 整形常量、实型常量、字符常量、字符串常量、枚举常量 变量的定义及其初始化 表达式的概念、左值和右值的概念 操作符的优先级与结合性 算术运算符、赋值运算符 ( 赋值构成一个表达式,因而它具有值 ) 增量和减量运算符 逗号表达式. 举例: 1. 变量的名称: way_cool, iPtr, _size, i1 都是合法的变量名,而 1day, a+b, dollar$ 等都是错误的变量名; 2. 表达式 2-1 ‘ 2 ’ – ‘ 1 ’ 的结果有何不同?.

gayle
Download Presentation

复 习

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 复 习

  2. 第3章 基本数据类型、运算符与表达式 • 掌握基本数据类型 • 整形常量、实型常量、字符常量、字符串常量、枚举常量 • 变量的定义及其初始化 • 表达式的概念、左值和右值的概念 • 操作符的优先级与结合性 • 算术运算符、赋值运算符(赋值构成一个表达式,因而它具有值) • 增量和减量运算符 • 逗号表达式

  3. 举例: 1. 变量的名称:way_cool, iPtr, _size, i1都是合法的变量名,而1day, a+b, dollar$等都是错误的变量名; 2. 表达式 2-1 ‘2’–‘1’ 的结果有何不同?

  4. 3. “0”,’0‘与 0 之间有什么区别, “0”占用几个内存空间? 4. 1/4 = ? 1./4 = ? 1.0/4.0 = ?

  5. 第4章 简单的C++程序设计 • C++的语句 • 控制语句、函数调用语句、表达式语句、空语句、复合语句 • C++的I/O流控制 • I/O的书写格式 • 控制符 • C语言的printf和scanf • 使用方法 • 格式控制字符串

  6. 举例: #include "stdio.h" void main( ) { int a, b=1, c=2; printf("%d,%d\n", a=(b++>1)?1:0, ++c); printf("%5.2f\n", b/c); }

  7. 第5章 选择结构程序设计 • 关系运算符和关系表达式 • 逻辑运算符和逻辑表达式 • if语句 • if语句的三种形式 • if语句的嵌套 • 条件运算符 • switch语句

  8. #include "stdio.h" void main( ) { int x = 3; if (--x<3) if (x--<5) printf("%d\n", x+5); else printf("%d\n", x--); printf("%d\n",--x); }

  9. 第6章 循环控制 • while语句 • do-while语句 • for语句 • 循环的嵌套 • 几种循环的比较 • break语句与continue语句

  10. 第7章 函数 • 函数定义 • 函数的参数与调用 • 形参和实参 • 函数的调用方法 • 递归函数 • 内联函数、重载函数、默认参数的函数 • 全局变量与局部变量 • 变量的存储类型 • 内部函数与外部函数 • 如何运行一个多文件的程序

  11. 第8章 数组 • 一维数组的定义和使用 • 数组定义 • 访问数组元素 • 数组元素的初始化 • 向函数传递数组 • 二维数组的定义和使用 • 二维数组定义 • 二维数组的初始化 • 作为参数传递 • 字符数组的定义和使用 • 常用字符串函数

  12. #include <iostream.h> void swap(int* p1, int* p2) { int temp; temp = *p1; *p1 = *p2; *p2 = temp; } void main() { int a=1,b=2; swap(&a, &b); cout << "a=" << a << ",b=" << b << endl; }

  13. void swap(int* p1, int* p2) { int* temp; temp = p1; p1 = p2; p2 = temp; }

  14. #include "stdio.h" void output(int* p, int n) { for (int i=0; i<n; ++i) printf("%d\n", *(p+i)); } void main( ) { int array[] = {1,2,3,4,5,6}; output(array+2, 2); }

  15. #include "stdio.h" void main() { int a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12}; int *p; for (p = a[0]; p < a[0]+12; p++) { if ((p-a[0])%4 == 0) printf("\n"); printf("%d,", *p); } }

  16. #include <iostream.h> void main() { int a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12}; int (*p)[4]; int i=2, j=3; p = a; cout<<"a["<<i<<","<<j<<"]=" <<*(*(p + i) +j)<<endl; }

  17. 第九章 指针 • 地址和指针的概念 • 指针:另一个变量的地址,用于间接访问变量 • 指针变量:用于存放地址的变量 • 指针运算 • 指针与数组 • 指针与函数 • 指针数组

  18. 多维数组与指针 • 指向函数的指针 • 指向指针的指针 • const指针、引用的概念、用指针动态分配内存

  19. 第10章 结构体 • 结构体和结构变量的定义 • 结构体变量成员的使用 • 结构体变量的赋值 • 结构体与函数

  20. 第11章 文件 • 文件的种类:二进制文件、ASCII文件 • 文件类型指针 • 文件的打开与关闭 • 文件使用方式 • 文件的读写

  21. 第12章 C++面向对象基础 • 面向对象语言的主要特点 • C++类的定义,对象的定义及使用 • 类的成员函数 • 构造函数、默认构造函数和析构函数

More Related