關于我們
書單推薦
新書推薦
|
C語言程序設計(第4版)(微課版) 讀者對象:本書可作為應用型本科院校、高等職業(yè)院校C語言課程的教材,也適合培訓和自學之用。
如何讓讀者在短時間內掌握C語言程序設計的方法,是編者編寫本書的目的。本書包括10 章:第 1~3 章介紹C 語言的基礎知識及基本程序結構;第4~6 章著重介紹數(shù)組、指針和函數(shù)的相關內容;第7 章簡要介紹編譯預處理;第8 章介紹結構體和鏈表;第9 章介紹文件的相關內容;第10 章介紹實訓項目。本書內容實用且通俗易讀,體系合理,既可作為高等職業(yè)院校學生的C 語言課程的教材,也可作為培訓機構的教材。
章曉勤,女,碩士,副教授,任職于安徽電子信息職業(yè)技術學院。多年來,一直從事計算機軟件技術專業(yè)的教學工作,主講多門計算機專業(yè)課程,編寫多部計算機專業(yè)教材,其中獲選“十二五”職業(yè)教育國家規(guī)劃教材一部,參與并作為主要完成人的項目曾獲國家教學成果二等獎。
第1 章 C 語言概述 ···························································································.1
1.1 C 語言產(chǎn)生的背景 ·················································································.1 1.2 C 語言的特點 ·······················································································.2 1.3 C 語言程序的結構 ·················································································.2 1.3.1 C 語言程序的基本單位 ···································································.2 1.3.2 C 語言函數(shù)的格式 ·········································································.2 1.3.3 關鍵字 ·······················································································.4 1.4 C 語言程序的集成開發(fā)環(huán)境 ·····································································.5 1.4.1 Dev-C++的安裝和使用 ···································································.5 1.4.2 Visual C++ 2010 的安裝和使用 ·························································.9 實訓1 認識C 語言程序 ········································································.16 本章小結 ··································································································.17 習題1 ······································································································.17 第2 章 數(shù)據(jù)類型、運算符與表達式 ·····································································.19 2.1 C 語言的數(shù)據(jù)類型 ················································································.19 2.2 常量與變量 ·························································································.20 2.2.1 直接常量和符號常量 ····································································.20 2.2.2 變量 ·························································································.22 2.2.3 常變量 ······················································································.22 2.3 整型數(shù)據(jù) ····························································································.23 2.3.1 整型常量 ···················································································.23 2.3.2 整型變量 ···················································································.24 實訓2 使用整型數(shù)據(jù) ···········································································.27 2.4 實型數(shù)據(jù) ····························································································.28 2.4.1 實型常量 ···················································································.28 2.4.2 實型變量 ···················································································.29 實訓3 使用實型數(shù)據(jù) ···········································································.30 2.5 字符型數(shù)據(jù) ·························································································.31 2.5.1 字符常量 ···················································································.31 2.5.2 字符變量 ···················································································.32 2.5.3 字符串常量 ················································································.34 實訓4 使用字符型數(shù)據(jù) ········································································.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 不同長度的數(shù)據(jù)進行位運算 ··························································.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 數(shù)據(jù)的輸入/輸出 ··················································································.61 3.3.1 字符輸入/輸出函數(shù)——putchar()函數(shù)和getchar()函數(shù) ····························.61 3.3.2 格式輸入/輸出函數(shù)——printf()函數(shù)和scanf()函數(shù) ································.63 實訓6 使用輸入/輸出函數(shù) ····································································.69 3.4 順序結構的程序設計 ·············································································.72 3.5 選擇結構的程序設計 ·············································································.73 3.5.1 if 語句 ·······················································································.73 3.5.2 switch 語句 ·················································································.78 實訓7 if 語句和switch 語句的使用 ·························································.80 3.6 循環(huán)結構的程序設計 ·············································································.85 3.6.1 goto 語句 ···················································································.85 3.6.2 while 語句、do-while 語句和for 語句 ················································.86 3.6.3 循環(huán)語句的嵌套結構 ····································································.91 3.6.4 break 語句和continue 語句 ·····························································.93 實訓8 while 語句、do-while 語句和for 語句的使用 ·····································.95 課程設計1 猜數(shù)字游戲 ············································································.103 本章小結 ································································································.105 習題3 ····································································································.105 第4 章 數(shù)組 ·································································································.111 4.1 一維數(shù)組 ··························································································.111 4.1.1 一維數(shù)組的定義、引用和初始化 ····················································.112 4.1.2 一維數(shù)組的應用 ········································································.116 實訓9 一維數(shù)組的使用 ······································································.117 4.2 二維數(shù)組 ··························································································.121 4.2.1 二維數(shù)組的定義 ········································································.122 4.2.2 二維數(shù)組的引用 ········································································.122 4.2.3 二維數(shù)組的初始化 ·····································································.123 實訓10 二維數(shù)組的使用 ·····································································.124 4.3 字符數(shù)組 ··························································································.128 4.3.1 字符數(shù)組的定義、引用和初始化 ····················································.128 4.3.2 字符串的輸入/輸出 ·····································································.129 4.3.3 字符串處理函數(shù) ········································································.131 實訓11 字符數(shù)組的使用 ·····································································.133 課程設計2 數(shù)組的增、刪、改、查 ·····························································.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 指針與數(shù)組 ·······················································································.146 5.2.1 指針與一維數(shù)組 ········································································.146 5.2.2 指針與二維數(shù)組 ········································································.149 5.2.3 指針數(shù)組和指向指針的指針 ··························································.151 5.2.4 指針數(shù)組作為main()函數(shù)的形參 ····················································.153 實訓13 指針的應用 ···········································································.154 本章小結 ································································································.158 習題5 ····································································································.158 第6 章 函數(shù) ·································································································.164 6.1 函數(shù)的定義 ·······················································································.164 實訓14 建立和使用函數(shù) ·····································································.166 6.2 函數(shù)的參數(shù)與返回值 ···········································································.168 6.2.1 形式參數(shù)與實際參數(shù) ··································································.168 6.2.2 參數(shù)的值傳遞方式和地址傳遞方式 ·················································.169 實訓15 參數(shù)的值傳遞方式和地址傳遞方式的應用 ····································.171 6.2.3 參數(shù)類型 ·················································································.172 實訓16 函數(shù)參數(shù)傳遞的方式 ·······························································.174 6.2.4 函數(shù)的返回值 ···········································································.175 實訓17 函數(shù)的返回值的應用 ·······························································.176 6.3 函數(shù)的調用 ·······················································································.178 6.3.1 調用函數(shù)的基本問題 ··································································.178 6.3.2 函數(shù)的嵌套調用 ········································································.180 6.3.3 函數(shù)的遞歸調用 ········································································.181 實訓18 嵌套調用與遞歸調用的實現(xiàn) ······················································.183 6.4 函數(shù)與指針 ·······················································································.185 6.4.1 返回指針值的函數(shù) ·····································································.185 6.4.2 指向函數(shù)的指針 ········································································.186 6.5 變量作用域和存儲類別 ········································································.188 6.5.1 局部變量 ·················································································.188 6.5.2 全局變量 ·················································································.189 6.5.3 變量的存儲類別 ········································································.191 實訓19 局部變量和全局變量的使用 ······················································.194 6.6 內部函數(shù)和外部函數(shù) ···········································································.195 6.6.1 內部函數(shù) ·················································································.195 6.6.2 外部函數(shù) ·················································································.195 課程設計3 模擬自動取款機 ······································································.196 本章小結 ································································································.199 習題6 ····································································································.200 第7 章 編譯預處理 ························································································.204 7.1 預處理命令概述 ·················································································.204 7.2 宏定義 ·····························································································.205 7.2.1 不帶參數(shù)的宏定義 ·····································································.205 7.2.2 帶參數(shù)的宏定義 ········································································.207 7.3 文件包含 ··························································································.210 7.4 條件編譯 ··························································································.211 實訓20 定義宏和使用宏 ·····································································.213 本章小結 ································································································.216 習題7 ····································································································.216 第8 章 結構體和鏈表 ·····················································································.220 8.1 結構體 ·····························································································.220 8.1.1 結構體的定義、引用和初始化 ·······················································.220 8.1.2 結構體數(shù)組和結構體指針 ·····························································.227 8.1.3 結構體與函數(shù) ···········································································.230 實訓21 結構體的應用 ········································································.233 8.2 鏈表 ································································································.234 8.2.1 鏈表的概念 ··············································································.234 8.2.2 鏈表的實現(xiàn) ··············································································.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 文件加密程序的實現(xiàn)及文件的讀/寫操作 ······································.264 9.4 文件定位與出錯檢測 ···········································································.269 9.4.1 文件定位函數(shù)——fseek()函數(shù) ·······················································.269 9.4.2 出錯檢測函數(shù)——ferror()函數(shù) ·······················································.269 9.5 其他文件函數(shù) ····················································································.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 姓名大作戰(zhàn) ·············································································.289 10.2 密碼管理系統(tǒng) ··················································································.291 10.2.1 系統(tǒng)基本需求 ··········································································.291 10.2.2 結構設計 ················································································.295 10.2.3 功能函數(shù)的實現(xiàn) ·······································································.296 10.2.4 項目總結 ················································································.301 附錄A 常用字符與標準ASCII 碼的對照表 ··························································.302 附錄B 運算符的優(yōu)先級和結合性 ······································································.304 附錄C 常用庫函數(shù) ························································································.306
你還可能感興趣
我要評論
|