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