关于我们
书单推荐
新书推荐
|
C语言程序设计(第4版)(微课版) 读者对象:本书可作为应用型本科院校、高等职业院校C语言课程的教材,也适合培训和自学之用。
如何让读者在短时间内掌握C语言程序设计的方法,是编者编写本书的目的。本书包括10 章:第 1~3 章介绍C 语言的基础知识及基本程序结构;第4~6 章着重介绍数组、指针和函数的相关内容;第7 章简要介绍编译预处理;第8 章介绍结构体和链表;第9 章介绍文件的相关内容;第10 章介绍实训项目。本书内容实用且通俗易读,体系合理,既可作为高等职业院校学生的C 语言课程的教材,也可作为培训机构的教材。
章晓勤,女,硕士,副教授,任职于安徽电子信息职业技术学院。多年来,一直从事计算机软件技术专业的教学工作,主讲多门计算机专业课程,编写多部计算机专业教材,其中获选“十二五”职业教育国家规划教材一部,参与并作为主要完成人的项目曾获国家教学成果二等奖。
第1 章 C 语言概述 ···························································································.1
1.1 C 语言产生的背景 ·················································································.1 1.2 C 语言的特点 ·······················································································.2 1.3 C 语言程序的结构 ·················································································.2 1.3.1 C 语言程序的基本单位 ···································································.2 1.3.2 C 语言函数的格式 ·········································································.2 1.3.3 关键字 ·······················································································.4 1.4 C 语言程序的集成开发环境 ·····································································.5 1.4.1 Dev-C++的安装和使用 ···································································.5 1.4.2 Visual C++ 2010 的安装和使用 ·························································.9 实训1 认识C 语言程序 ········································································.16 本章小结 ··································································································.17 习题1 ······································································································.17 第2 章 数据类型、运算符与表达式 ·····································································.19 2.1 C 语言的数据类型 ················································································.19 2.2 常量与变量 ·························································································.20 2.2.1 直接常量和符号常量 ····································································.20 2.2.2 变量 ·························································································.22 2.2.3 常变量 ······················································································.22 2.3 整型数据 ····························································································.23 2.3.1 整型常量 ···················································································.23 2.3.2 整型变量 ···················································································.24 实训2 使用整型数据 ···········································································.27 2.4 实型数据 ····························································································.28 2.4.1 实型常量 ···················································································.28 2.4.2 实型变量 ···················································································.29 实训3 使用实型数据 ···········································································.30 2.5 字符型数据 ·························································································.31 2.5.1 字符常量 ···················································································.31 2.5.2 字符变量 ···················································································.32 2.5.3 字符串常量 ················································································.34 实训4 使用字符型数据 ········································································.35 2.6 算术运算符和算术表达式 ·······································································.36 2.7 赋值运算符和赋值表达式 ·······································································.38 2.8 关系运算符和关系表达式 ·······································································.43 2.9 逻辑运算符与逻辑表达式 ·······································································.44 2.10 逗号运算符和逗号表达式 ·····································································.46 2.11 位运算 ·····························································································.47 2.11.1 位逻辑运算符 ············································································.48 2.11.2 移位运算符 ···············································································.50 2.11.3 位赋值运算符 ············································································.50 2.11.4 不同长度的数据进行位运算 ··························································.51 实训5 使用运算符和表达式 ··································································.51 本章小结 ··································································································.54 习题2 ······································································································.54 第3 章 基本程序结构 ·······················································································.58 3.1 C 语言程序的3 种基本结构 ····································································.58 3.2 C 语言语句 ·························································································.59 3.2.1 C 语言语句的类型 ········································································.59 3.2.2 赋值语句 ···················································································.60 3.3 数据的输入/输出 ··················································································.61 3.3.1 字符输入/输出函数——putchar()函数和getchar()函数 ····························.61 3.3.2 格式输入/输出函数——printf()函数和scanf()函数 ································.63 实训6 使用输入/输出函数 ····································································.69 3.4 顺序结构的程序设计 ·············································································.72 3.5 选择结构的程序设计 ·············································································.73 3.5.1 if 语句 ·······················································································.73 3.5.2 switch 语句 ·················································································.78 实训7 if 语句和switch 语句的使用 ·························································.80 3.6 循环结构的程序设计 ·············································································.85 3.6.1 goto 语句 ···················································································.85 3.6.2 while 语句、do-while 语句和for 语句 ················································.86 3.6.3 循环语句的嵌套结构 ····································································.91 3.6.4 break 语句和continue 语句 ·····························································.93 实训8 while 语句、do-while 语句和for 语句的使用 ·····································.95 课程设计1 猜数字游戏 ············································································.103 本章小结 ································································································.105 习题3 ····································································································.105 第4 章 数组 ·································································································.111 4.1 一维数组 ··························································································.111 4.1.1 一维数组的定义、引用和初始化 ····················································.112 4.1.2 一维数组的应用 ········································································.116 实训9 一维数组的使用 ······································································.117 4.2 二维数组 ··························································································.121 4.2.1 二维数组的定义 ········································································.122 4.2.2 二维数组的引用 ········································································.122 4.2.3 二维数组的初始化 ·····································································.123 实训10 二维数组的使用 ·····································································.124 4.3 字符数组 ··························································································.128 4.3.1 字符数组的定义、引用和初始化 ····················································.128 4.3.2 字符串的输入/输出 ·····································································.129 4.3.3 字符串处理函数 ········································································.131 实训11 字符数组的使用 ·····································································.133 课程设计2 数组的增、删、改、查 ·····························································.134 本章小结 ································································································.136 习题4 ····································································································.137 第5 章 指针 ·································································································.143 5.1 指针和指针变量 ·················································································.143 5.1.1 变量的地址 ··············································································.143 5.1.2 变量的指针和指针变量································································.144 5.1.3 取地址运算符和指针运算符 ··························································.144 实训12 指针的初步应用 ·····································································.145 5.2 指针与数组 ·······················································································.146 5.2.1 指针与一维数组 ········································································.146 5.2.2 指针与二维数组 ········································································.149 5.2.3 指针数组和指向指针的指针 ··························································.151 5.2.4 指针数组作为main()函数的形参 ····················································.153 实训13 指针的应用 ···········································································.154 本章小结 ································································································.158 习题5 ····································································································.158 第6 章 函数 ·································································································.164 6.1 函数的定义 ·······················································································.164 实训14 建立和使用函数 ·····································································.166 6.2 函数的参数与返回值 ···········································································.168 6.2.1 形式参数与实际参数 ··································································.168 6.2.2 参数的值传递方式和地址传递方式 ·················································.169 实训15 参数的值传递方式和地址传递方式的应用 ····································.171 6.2.3 参数类型 ·················································································.172 实训16 函数参数传递的方式 ·······························································.174 6.2.4 函数的返回值 ···········································································.175 实训17 函数的返回值的应用 ·······························································.176 6.3 函数的调用 ·······················································································.178 6.3.1 调用函数的基本问题 ··································································.178 6.3.2 函数的嵌套调用 ········································································.180 6.3.3 函数的递归调用 ········································································.181 实训18 嵌套调用与递归调用的实现 ······················································.183 6.4 函数与指针 ·······················································································.185 6.4.1 返回指针值的函数 ·····································································.185 6.4.2 指向函数的指针 ········································································.186 6.5 变量作用域和存储类别 ········································································.188 6.5.1 局部变量 ·················································································.188 6.5.2 全局变量 ·················································································.189 6.5.3 变量的存储类别 ········································································.191 实训19 局部变量和全局变量的使用 ······················································.194 6.6 内部函数和外部函数 ···········································································.195 6.6.1 内部函数 ·················································································.195 6.6.2 外部函数 ·················································································.195 课程设计3 模拟自动取款机 ······································································.196 本章小结 ································································································.199 习题6 ····································································································.200 第7 章 编译预处理 ························································································.204 7.1 预处理命令概述 ·················································································.204 7.2 宏定义 ·····························································································.205 7.2.1 不带参数的宏定义 ·····································································.205 7.2.2 带参数的宏定义 ········································································.207 7.3 文件包含 ··························································································.210 7.4 条件编译 ··························································································.211 实训20 定义宏和使用宏 ·····································································.213 本章小结 ································································································.216 习题7 ····································································································.216 第8 章 结构体和链表 ·····················································································.220 8.1 结构体 ·····························································································.220 8.1.1 结构体的定义、引用和初始化 ·······················································.220 8.1.2 结构体数组和结构体指针 ·····························································.227 8.1.3 结构体与函数 ···········································································.230 实训21 结构体的应用 ········································································.233 8.2 链表 ································································································.234 8.2.1 链表的概念 ··············································································.234 8.2.2 链表的实现 ··············································································.235 8.2.3 链表的操作 ··············································································.238 8.3 共用体类型和枚举类型 ········································································.242 8.3.1 共用体类型的定义、使用和初始化 ·················································.242 8.3.2 枚举类型的定义、使用和初始化 ····················································.244 8.4 类型定义 ··························································································.245 课程设计4 学生管理程序 ·········································································.246 本章小结 ································································································.251 习题8 ····································································································.251 第9 章 文件 ·································································································.256 9.1 文件类型指针 ····················································································.258 9.2 文件的打开与关闭 ··············································································.259 9.3 文件的读/写操作 ················································································.261 实训22 文件加密程序的实现及文件的读/写操作 ······································.264 9.4 文件定位与出错检测 ···········································································.269 9.4.1 文件定位函数——fseek()函数 ·······················································.269 9.4.2 出错检测函数——ferror()函数 ·······················································.269 9.5 其他文件函数 ····················································································.270 实训23 文件定位操作 ········································································.271 课程设计5 学生管理程序(文件版本) ························································.273 本章小结 ································································································.278 习题9 ····································································································.279 第10 章 实训项目 ·························································································.281 10.1 趣味程序 ························································································.281 10.1.1 移动的心 ················································································.281 10.1.2 彩色文字 ················································································.284 10.1.3 五子棋 ···················································································.285 10.1.4 姓名大作战 ·············································································.289 10.2 密码管理系统 ··················································································.291 10.2.1 系统基本需求 ··········································································.291 10.2.2 结构设计 ················································································.295 10.2.3 功能函数的实现 ·······································································.296 10.2.4 项目总结 ················································································.301 附录A 常用字符与标准ASCII 码的对照表 ··························································.302 附录B 运算符的优先级和结合性 ······································································.304 附录C 常用库函数 ························································································.306
你还可能感兴趣
我要评论
|