當前位置:首頁 » 招生排名 » c大學基礎教程答案

c大學基礎教程答案

發布時間: 2022-02-27 00:12:55

『壹』 求《C 大學教程》/《C how to program》第6版deitel著 課後練習答案

第五版 課後答案 (H.M.Deitel)

http://www.daanwang.com/download/90970-.html
http://www.daanwang.com/download/90970-.html
要求注冊登陸

『貳』 求《C++大學基礎教程》 第五版 deitel 著 電子工業出版社 課後答案 是基礎教程!!!

C 大學基礎教程 課後答案DEITEL版 3.11 GradeBook類定義 include ltstringgt // program uses C standard string class using std::string class GradeBook public: // constructor initializes course name and instructor name GradeBook string string void setCourseName string // function to set the course name string getCourseName // function to retrieve the course name void setInstructorName string // function to set instructor name string getInstructorName // function to retrieve instructor name void displayMessage // display welcome message and instructor name private: string courseName // course name for this GradeBook string instructorName // instructor name for this GradeBook // end class GradeBook 類成員函數 include ltiostreamgt using std::cout using std::endl include quotGradeBook.hquot // constructor initializes courseName and instructorName // with strings supplied as arguments GradeBook::GradeBook string course string instructor setCourseName course // initializes courseName setInstructorName instructor // initialiZes instructorName // end GradeBook constructor // function to set the course name void GradeBook::setCourseName string name courseName name // store the course name // end function setCourseName // function to retrieve the course name string GradeBook::getCourseName return courseName // end function getCourseName // function to set the instructor name void GradeBook::setInstructorName string name instructorName name // store the instructor name // end function setInstructorName // function to retrieve the instructor name string GradeBook::getInstructorName return instructorName // end function getInstructorName // display a welcome message and the instructors name void GradeBook::displayMessage // display a welcome message containing the course name cout ltlt quotWelcome to the grade book fornquot ltlt getCourseName ltlt quotquot ltlt endl // display the instructors name cout ltlt quotThis course is presented by: quot ltlt getInstructorName ltlt endl // end function displayMessage 測試文件 include ltiostreamgt using std::cout using std::endl // include definition of class GradeBook from GradeBook.h include quotGradeBook.hquot // function main begins program execution int main // create a GradeBook object pass a course name and instructor name GradeBook gradeBook quotCS101 Introction to C Programmingquot quotProfessor Smithquot // display initial value of instructorName of GradeBook object cout ltlt quotgradeBook instructor name is: quot ltlt gradeBook.getInstructorName ltlt quotnnquot // modify the instructorName using set function gradeBook.setInstructorName quotAssistant Professor Batesquot // display new value of instructorName cout ltlt quotnew gradeBook instructor name is: quot ltlt gradeBook.getInstructorName ltlt quotnnquot // display welcome message and instructors name gradeBook.displayMessage return 0 // indicate successful termination // end main 3.12 類定義 class Account public: Account int // constructor initializes balance void credit int // add an amount to the account balance void debit int // subtract an amount from the account balance int getBalance // return the account balance private: int balance // data member that stores the balance // end class Account 類成員函數 include ltiostreamgt using std::cout using std::endl include quotAccount.hquot // include definition of class Account // Account constructor initializes data member balance Account::Account int initialBalance balance 0 // assume that the balance begins at 0 // if initialBalance is greater than 0 set this value as the // balance of the Account otherwise balance remains 0 if initialBalance gt 0 balance initialBalance // if initialBalance is negative print error message if initialBalance lt 0 cout ltlt quotError: Initial balance cannot be negative.nquot ltlt endl // end Account constructor // credit add an amount to the account balance void Account::credit int amount balance balance amount // add amount to balance // end function credit // debit subtract an amount from the account balance void Account::debit int amount if amount gt balance // debit amount exceeds balance cout ltlt quotDebit amount exceeded account balance.nquot ltlt endl if amount lt balance // debit amount does not exceed balance balance balance - amount // end function debit // return the account balance int Account::getBalance return balance // gives the value of balance to the calling function // end function getBalance 測試函數 include ltiostreamgt using std::cout using std::cin using std::endl // include definition of class Account from Account.h include quotAccount.hquot // function main begins program execution int main Account account1 50 // create Account object Account account2 25 // create Account object // display initial balance of each object cout ltlt quotaccount1 balance: quot ltlt account1.getBalance ltlt endl cout ltlt quotaccount2 balance: quot ltlt account2.getBalance ltlt endl int withdrawalAmount // stores withdrawal amount read from user cout ltlt quotnEnter withdrawal amount for account1: quot // prompt cin gtgt withdrawalAmount // obtain user input cout ltlt quotnattempting to subtract quot ltlt withdrawalAmount ltlt quot from account1 balancennquot account1.debit withdrawalAmount // try to subtract from account1 // display balances cout ltlt quotaccount1 balance: quot ltlt account1.getBalance ltlt endl cout ltlt quotaccount2 balance: quot ltlt account2.getBalance ltlt endl cout ltlt quotnEnter withdrawal amount for account2: quot // prompt cin gtgt withdrawalAmount // obtain user input cout ltlt quotnattempting to subtract quot ltlt withdrawalAmount ltlt quot from account2 balancennquot account2.debit withdrawalAmount // try to subtract from account2 // display balances cout ltlt quotaccount1 balance: quot ltlt account1.getBalance ltlt endl cout ltlt quotaccount2 balance: quot ltlt account2.getBalance ltlt endl return 0 // indicate successful termination // end main 3.13 類定義 include ltstringgt // program uses C standard string class using std::string // Invoice class definition class Invoice public: // constructor initializes the four data members Invoice string string int int // set and get functions for the four data members void setPartNumber string // part number string getPartNumber void setPartDescription string // part description string getPartDescription void setQuantity int // quantity int getQuantity void setPricePerItem int // price per item int getPricePerItem // calculates invoice amount by multiplying quantity x price per item int getInvoiceAmount private: string partNumber // the number of the part being sold string partDescription // description of the part being sold int quantity // how many of the items are being sold int pricePerItem // price per item // end class Invoice 類成員函數 include ltiostreamgt using std::cout using std::endl // include definition of class Invoice from Invoice.h include quotInvoice.hquot // Invoice constructor initializes the classs four data members Invoice::Invoice string number string description int count int price setPartNumber number // store partNumber setPartDescription description // store partDescription setQuantity count // validate and store quantity setPricePerItem price // validate and store pricePerItem // end Invoice constructor // set part number void Invoice::setPartNumber string number partNumber number // no validation needed // end function setPartNumber // get part number string Invoice::getPartNumber return partNumber // end function getPartNumber // set part description void Invoice::setPartDescription string description partDescription description // no validation needed // end function setPartDescription // get part description string Invoice::getPartDescription return partDescription // end function getPartDescription // set quantity if not positive set to 0 void Invoice::setQuantity int count if count gt 0 // if quantity is positive quantity count // set quantity to count if count lt 0 // if quantity is not positive quantity 0 // set quantity to 0 cout ltlt quotnquantity cannot be negative. quantity set to 0.nquot // end if // end function setQuantity // get quantity int Invoice::getQuantity return quantity // end function getQuantity // set price per item if not positive set to 0 void Invoice::setPricePerItem int price if price gt 0 // if price is positive pricePerItem price // set pricePerItem to price if price lt 0 // if price is not positive pricePerItem 0 // set pricePerItem to 0 cout ltlt quotnpricePerItem cannot be negative. quot ltlt quotpricePerItem set to 0.nquot // end if // end function setPricePerItem // get price per item int Invoice::getPricePerItem return pricePerItem // end function getPricePerItem // calulates invoice amount by multiplying quantity x price per item int Invoice::getInvoiceAmount return getQuantity getPricePerItem // end function getInvoiceAmount 測試函數 include ltiostreamgt using std::cout using std::cin using std::endl // include definition of class Invoice from Invoice.h include quotInvoice.hquot // function main begins program execution int main // create an Invoice object Invoice invoice quot12345quot quotHammerquot 100 5 // display the invoice data members and calculate the amount cout ltlt quotPart number: quot ltlt invoice.getPartNumber ltlt endl cout ltlt quotPart description: quot ltlt invoice.getPartDescription ltlt endl cout ltlt quotQuantity: quot ltlt invoice.getQuantity ltlt endl cout ltlt quotPrice per item: quot ltlt invoice.getPricePerItem ltlt endl cout ltlt quotInvoice amount: quot ltlt invoice.getInvoiceAmount ltlt endl // modify the invoice data members invoice.setPartNumber quot123456quot invoice.setPartDescription quotSawquot invoice.setQuantity -5 //negative quantityso quantity set to 0 invoice.setPricePerItem 10 cout ltlt quotnInvoice data members modified.nnquot // display the modified invoice data members and calculate new amount cout ltlt quotPart number: quot ltlt invoice.getPartNumber ltlt endl cout ltlt quotPart description: quot ltlt invoice.getPartDescription ltlt endl cout ltlt quotQuantity: quot ltlt invoice.getQuantity ltlt endl cout ltlt quotPrice per item: quot ltlt invoice.getPricePerItem ltlt endl cout ltlt quotInvoice amount: quot ltlt invoice.getInvoiceAmount ltlt endl return 0 // indicate successful termination // end main 3.14 類定義 include ltstringgt // program uses C standard string class using std::string // Employee class definition class Employee public: Employee string string int // constructor sets data members void setFirstName string // set first name string getFirstName // return first name void setLastName string // set last name string getLastName // return last name void setMonthlySalary int // set weekly salary int getMonthlySalary // return weekly salary private: string firstName // Employees first name string lastName // Employees last name int monthlySalary // Employees salary per month // end class Employee 類成員函數 include ltiostreamgt using std::cout include quotEmployee.hquot // Employee class definition // Employee constructor initializes the three data members Employee::Employee string first string last int salary setFirstName first // store first name setLastName last // store last name setMonthlySalary salary // validate and store monthly salary // end Employee constructor // set first name void Employee::setFirstName string name firstName name // no validation needed // end function setFirstName // return first name string Employee::getFirstName return firstName // end function getFirstName // set last name void Employee::setLastName string name lastName name // no validation needed // end function setLastName // return last name string Employee::getLastName return lastName // end function getLastName // set monthly salary if not positive set to 0.0 void Employee::setMonthlySalary int salary if salary gt 0 // if salary is positive monthlySalary salary // set monthlySalary to salary if salary lt 0 // if salary is not positive monthlySalary 0 // set monthlySalary to 0.0 // end function setMonthlySalary // return monthly salary int Employee::getMonthlySalary return monthlySalary // end function getMonthlySalary 測試函數 include ltiostreamgt using std::cout using std::endl include quotEmployee.hquot // include definition of class Employee // function main begins program execution int main // create two Employee objects Employee employee1 quotLisaquot quotRobertsquot 4500 Employee employee2 quotMarkquot quotSteinquot 4000 // display each Employees yearly salary cout ltlt quotEmployees yearly salaries: quot ltlt endl // retrieve and display employee1s monthly salary multiplied by 12 int monthlySalary1 employee1.getMonthlySalary cout ltlt employee1.getFirstName ltlt quot quot ltlt employee1.getLastName ltlt quot: quot ltlt monthlySalary1 12 ltlt endl // retrieve and display employee2s monthly salary multiplied by 12 int monthlySalary2 employee2.getMonthlySalary cout ltlt employee2.getFirstName ltlt quot quot ltlt employee2.getLastName ltlt quot: quot ltlt monthlySalary2 12 ltlt endl // give each Employee a 10 raise employee1.setMonthlySalary monthlySalary1 1.1 employee2.setMonthlySalary monthlySalary2 1.1 // display each Employees yearly salary again cout ltlt quotnEmployees yearly salaries after 10 raise: quot ltlt endl // retrieve and display employee1s monthly salary multiplied by 12 monthlySalary1 employee1.getMonthlySalary cout ltlt employee1.getFirstName ltlt quot quot ltlt employee1.getLastName ltlt quot: quot ltlt monthlySalary1 12 ltlt endl monthlySalary2 employee2.getMonthlySalary cout ltlt employee2.getFirstName ltlt quot quot ltlt employee2.getLastName ltlt quot: quot ltlt monthlySalary2 12 ltlt endl return 0 // indicate successful termination // end main 3.15 類定義 class Date public: Date int int int // constructor initializes data members void setMonth int // set month int getMonth // return month void setDay int // set day int getDay // return day void setYear int // set year int getYear // return year void displayDate // displays date in mm/dd/yyyy format private: int month // the month of the date int day // the day of the date int year // the year of the date // end class Date 類成員函數 include ltiostreamgt using std::cout using std::endl include quotDate.hquot // include definition of class Date from Date.h // Date constructor that initializes the three data members // assume values provided are correct really should validate Date::Date int m int d int y setMonth m setDay d setYear y // end Date constructor // set month void Date::setMonth int m month m if month lt 1 month 1 if month gt 12 month 1 // end function setMonth // return month int Date::getMonth return month // end function getMonth // set day void Date::setDay int d day d // end function setDay // return day int Date::getDay return day // end function getDay // set year void Date::setYear int y year y // end function setYear // return year int Date::getYear return year // end function getYear // print Date in the format mm/dd/yyyy void Date::displayDate cout ltlt month ltlt / ltlt day ltlt / ltlt year ltlt endl // end function displayDate 測試函數 include ltiostreamgt using std::cout using std::endl include quotDate.hquot // include definition of class Date.

『叄』 求練習題答案,戴特爾著 c語言大學教程 第六版

哎,我也是跟樓主同求,買了這本書,其他都好,就是沒答案……

『肆』 標准C語言基礎教程(第四版)答案,,,,,急求,,,,

網路搜索一下。

『伍』 c語言基礎教程(c99版)

C語言基礎教程別看了,學習C語言不能脫離具體的系統,不能不了解計算機體系結構和操作系統原理、編譯原理,推薦你看這本開源的書:
《Linux C編程一站式學習》

如果是在Windows上學習,可以安裝cygwin來模擬linux環境,下載地址:

下面貼一下這本書的介紹,磨刀不誤砍柴工,看過之後你就會愛上這本書了:

這本書有什麼特點?面向什麼樣的讀者?

這本書最初是為北京亞嵌教育研究中心的嵌入式Linux系統工程師就業班課程量身定做的教材之一。該課程是為期四個月的全日制職業培訓,要求學員畢業時具備非常Solid的C編程能力,能熟練地使用Linux系統,同時對計算機體系結構與指令集、操作系統原理和設備驅動程序都有較深入的了解。然而學員入學時的水平是非常初級而且參差不齊的:學歷有專科、本科也有研究生,專業有和計算機相關的也有很不相關的(例如會計專業),以前從事的職業有和技術相關的也有完全不相關的(例如HR),年齡從二十齣頭到三十五六歲的都有。這么多背景完全不同、基礎完全不同、思維習慣和理解能力完全不同的人來聽同一堂課,大家都迫切希望學會嵌入式開發技術,投身IT行業,這就是職業教育的特點,也是我編這本書時需要考慮的主要問題。

學習編程絕不是一件簡單的事,尤其是對於零基礎的初學者來說。大學的計算機專業有四年時間從零基礎開始培養一個人,微積分、線代、隨機、離散、組合、自動機、編譯原理、操作系統、計算機組成原理等等一堆基礎課,再加上C/C++、Java、資料庫、網路、軟體工程、計算機圖形學等等一堆專業課,最後培養出一個能找到工作的學生。很遺憾這最後一條很多學校沒有做好,來亞嵌培訓的很多學生就是四年這么學過來的,但據我們考查他們的基礎幾乎為零,我不知道為什麼。與之形成鮮明對比的是,只給我們四個月的時間,同樣要求從零基礎開始,最後培養出一個能找到工作的學生,而且還要保證他找到工作,這就是職業教育的特點。

為什麼我說「只給我們四個月的時間」?我們倒是想教四年呢,但學時的長短我們做不了主,是由市場規律決定的。四年的任務要求四個月做好,要怎麼完成這樣一個幾乎不可能的任務?有些職業教育給出的答案是「實用主義」,打出了「有用就學,沒有用就不學」的口號,大肆貶低說大學里教的基礎課都是過時的、無用的,只有他們教的技術才是實用的,這種炒作很不好,我認為大學里教的每一門課都是非常有用的,基礎知識在任何時候都不會過時,倒是那些時髦的「實用技術」有可能很快就過時了。

四年的任務怎麼才能用四個月做好?我們給出的答案是「優化」。現在大學里安排的課程體系最大的缺點就是根本不考慮優化。每個過來人都會有這樣的感覺:大一大二學了好多數學課,卻不知道都是干什麼用的,為什麼要學。連它有什麼用都不知道怎麼能有興趣學好呢?然後到大三大四學專業課時,用到以前的知識了,才發現以前學的數學是多麼有用,然而早就忘得一干二凈了,考完試都還給老師了,回頭重新學吧,這時候才發現很多東西以前根本沒學明白,現在才真的學明白了,那麼前兩年的時間豈不是都浪費了?大學里的課程體系還有一個缺點就是不靈活,每門課必須佔一個學期,必須由一個老師教,不同課程的老師之間沒有任何溝通和銜接,其實這些課程之間是相互依賴的,把它們強行拆開是不符合人的認知規律的。比如我剛上大學的時候,大一上半學期就被逼著學C語言,其實C語言是一門很難的編程語言,不懂編譯原理、操作系統和計算機體系結構根本不可能學明白,那半個學期自然就浪費掉了。當時幾乎所有學校的計算機相關專業都是這樣,大一上來就學C語言,有的學校更瘋狂,上來就學C++,導致大多數學生都以為自己會C語言,但其實都是半吊子水平,到真正寫代碼的時候經常為一個Bug搞得焦頭爛額,卻沒有機會再系統地學一遍C語言,因為在學校看來,C語言課早在大一就給你「上完了」,就像一頓飯已經吃完了,不管你吃飽沒吃飽,不會再讓你重吃一遍了。顯而易見,如果要認真地對這些課程做優化,的確是有很多水份可以擠的。

本書有以下特點:

*

不是孤立地講C語言,而是和編譯原理、操作系統、計算機體系結構結合起來講。或者說,本書的內容只是以C語言為載體,真正講的是計算機的原理和程序的原理。
*

強調基本概念和基本原理,在編排順序上非常重視概念之間的依賴關系,每次引入一個新的概念,只依賴於前面章節已經講過的概念,而絕不會依賴後面章節要講的概念。有些地方為了敘述得完整,也會引用後面要講的內容,比如說「有關XX我們到XX章再仔細講解」,凡是這種引用都不是必要的依賴,可以當它不存在,只管繼續往下看就行了。
*

盡量做到每個知識點直到要用的時候才引入。過早引入一個知識點,講完了又不用它,讀者很快就會遺忘,這是不符合認知規律的。

這是一本從零基礎開始學習編程的書,不要求讀者有任何編程經驗,但讀者至少需要具備以下素質:

*

熟悉Linux系統的基本操作。如果不具備這一點,請先參考其它教材學習Linux系統的基本操作,熟練之後再學習本書,《鳥哥的Linux私房菜》據說是 Linux系統管理和應用方面比較好的一本書。但學習本書並不需要會很多系統管理技術,只要會用基本命令,會自己安裝系統和軟體包就足夠了。
*

具有高中畢業的數學水平。本書會用到高中的數學知識,事實上,如果不具有高中畢業的數學水平,也不必考慮做程序員了。但並不是說只要具有高中畢業的數學水平就足夠做程序員了,只能說看這本書應該沒有問題,數學是程序員最重要的修養,計算機科學其實就是數學的一個分支,如果你的數學功底很差,日後還需惡補一下。
*

具有高中畢業的英文水平。理由同上。
*

對計算機的原理和本質深感興趣,不是為就業而學習,不是為拿高薪而學習,而是真的感興趣,想把一切來龍去脈搞得清清楚楚而學習。
*

勤於思考。本書盡最大努力理清概念之間的依賴關系,力求一站式學習,讀者不需要為了找一個概念的定義去翻其它書,也不需要為了搞清楚一個概念在本書中前後一通亂翻,只需從前到後按順序學習即可。但一站式學習並不等於傻瓜式學習,有些章節有一定的難度,需要積極思考才能領會。本書可以替你節省時間,但不能替你思考,不要指望像看小說一樣走馬觀花看一遍就能學會。

又是一本C語言書。好吧,為什麼我要學這本書而不是譚浩強或者K&R? 請點評

譚浩強的書我就不說什麼了。居然教學生include一個.c文件。

K&R 是公認的世界上最經典的C語言教程,這點毫無疑問。在C標准出台之前,K&R第一版就是事實上的C標准。C89標准出台之後,K&R跟著標准推出了第二版,可惜此後就沒有更新過了,所以不能反映C89之後C語言的發展以及最新的C99標准,本書在這方面做了很多補充。上面我說過了,這本書與其說是講C語言,不如說是以C語言為載體講計算機和操作系統的原理,而K&R就是為了講C語言而講C語言,側重點不同,內容編排也很不相同。 K&R寫得非常好,代碼和語言都非常簡潔,但很可惜,只有會C語言的人才懂得欣賞它,K&R是非常不適合入門學習的,尤其不適合零基礎的學生入門學習。
這本書「是什麼」和「不是什麼」 請點評

本書包括三大部分:

*

C語言入門。介紹基本的C語法,幫助沒有任何編程經驗的讀者理解什麼是程序,怎麼寫程序,培養程序員的思維習慣,找到編程的感覺。前半部分改編自[ThinkCpp]。
*

C語言本質。結合計算機和操作系統的原理講解C程序是怎麼編譯、鏈接、運行的,同時全面介紹C的語法。位運算的章節改編自亞嵌教育林小竹老師的講義,鏈表和二叉樹的章節改編自亞嵌教育朱老師的講義。匯編語言的章節改編自[GroudUp],在該書的最後一章提到,學習編程有兩種Approach,一種是Bottom Up,一種是Top Down,各有優缺點,需要兩者結合起來。所以我編這本書的思路是,第一部分Top Down,第二部分Bottom Up,第三部分可以算填了中間的空隙,三部分全都圍繞C語言展開。
*

Linux系統編程。介紹各種Linux系統函數和內核的工作原理。Socket編程的章節改編自亞嵌教育衛劍釩老師的講義。

這本書定位在入門級,雖然內容很多,但不是一本網路全書,除了C語言基本要講透之外其它內容都不深入,書中列出了很多參考資料,是讀者進一步學習的起點。 K&R的第一章是一個Whirlwind Tour,把全書的內容簡單過了一遍,然後再逐個深入進去講解。本書也可以看作是計算機專業課程體系的一個Whirlwind Tour,學習完本書之後有了一個全局觀,再去學習那些參考資料就應該很容易上手了。
為什麼要在Linux平台上學C語言?用Windows學C語言不好嗎? 請點評

用 Windows還真的是學不好C語言。C語言是一種面向底層的編程語言,要寫好C程序,必須對操作系統的工作原理非常清楚,因為操作系統也是用C寫的,我們用C寫應用程序直接使用操作系統提供的介面。既然你選擇了看這本書,你一定了解:Linux是一種開源的操作系統,你有任何疑問都可以從源代碼和文檔中找到答案,即使你看不懂源代碼,也找不到文檔,也很容易找個高手教你,各種郵件列表、新聞組和論壇上從來都不缺樂於助人的高手;而Windows是一種封閉的操作系統,除了微軟的員工別人都看不到它的源代碼,只能通過文檔去猜測它的工作原理,更糟糕的是,微軟向來喜歡藏著揶著,好用的功能留著自己用,而不會寫到文檔里公開。本書的第一部分在Linux或Windows平台上學習都可以,但第二部分和第三部分介紹了很多Linux操作系統的原理以幫助讀者更深入地理解C語言,只能在Linux平台上學習。

Windows平台上的開發工具往往和各種集成開發環境(IDE,Integrated Development Environment)綁在一起,例如Visual Studio、Eclipse等。使用IDE確實很便捷,但IDE對於初學者絕對不是好東西。微軟喜歡宣揚傻瓜式編程的理念,告訴你用滑鼠拖幾個控制項,然後點一個按鈕就可以編譯出程序來,但是真正有用的程序有哪個是這么拖出來的?很多從Windows平台入門學編程的人,編了好幾年程序,還是只知道編完程序點一個按鈕就可以跑了,把幾個源文件拖到一個項目里就可以編譯到一起了,如果有更復雜的需求他們就傻眼了,因為他們腦子里只有按鈕、菜單的概念,根本沒有編譯器、鏈接器、Makefile的概念,甚至連命令行都沒用過,然而這些都是初學編程就應該建立起來的基本概念。另一方面,編譯器、鏈接器和C語言的語法有密切的關系,不了解編譯器、鏈接器的工作原理,也不可能真正掌握C的語法。所以,IDE並沒有幫助你學習,而是阻礙了你學習,本來要學好C編程只要把語法和編譯命令學會就行了,現在有了IDE,除了學會語法和編譯命令,你還得弄清楚編譯命令和IDE是怎麼集成的,這才算學明白了,本來就很復雜的學習任務被IDE搞得更加復雜了。Linux用戶的使用習慣從來都是以敲命令為主,以滑鼠操作為輔,從學編程的第一天起就要敲命令編譯程序,等到你把這些基本概念都搞清楚了,你覺得哪個IDE好用你再去用,不過到那時候你可能會更喜歡vi或emacs而不是IDE了。

『陸』 c++程序設計基礎教程課後答案(清華大學出版社鄭莉 董淵著)

第 一 章 概述

1-1 簡述計算機程序設計語言的發展歷程。

解:
迄今為止計算機程序設計語言的發展經歷了機器語言、匯編語言、高級語言等階段,C++語言是一種面向對象的編程語言,也屬於高級語言。

1-2 面向對象的編程語言有哪些特點?

解:
面向對象的編程語言與以往各種編程語言有根本的不同,它設計的出發點就是為了能更直接的描述客觀世界中存在的事物以及它們之間的關系。面向對象的編程語言將客觀事物看作具有屬性和行為的對象,通過抽象找出同一類對象的共同屬性(靜態特徵)和行為(動態特徵),形成類。通過類的繼承與多態可以很方便地實現代碼重用,大大縮短了軟體開發周期,並使得軟體風格統一。因此,面向對象的編程語言使程序能夠比較直接地反問題域的本來面目,軟體開發人員能夠利用人類認識事物所採用的一般思維方法來進行軟體開發。C++語言是目前應用最廣的面向對象的編程語言。

1-3 什麼是結構化程序設計方法?這種方法有哪些優點和缺點?

解:
結構化程序設計的思路是:自頂向下、逐步求精;其程序結構是按功能劃分為若干個基本模塊;各模塊之間的關系盡可能簡單,在功能上相對獨立;每一模塊內部均是由順序、選擇和循環三種基本結構組成;其模塊化實現的具體方法是使用子程序。結構化程序設計由於採用了模塊分解與功能抽象,自頂向下、分而治之的方法,從而有效地將一個較復雜的程序系統設計任務分解成許多易於控制和處理的子任務,便於開發和維護。
雖然結構化程序設計方法具有很多的優點,但它仍是一種面向過程的程序設計方法,它把數據和處理數據的過程分離為相互獨立的實體。當數據結構改變時,所有相關的處理過程都要進行相應的修改,每一種相對於老問題的新方法都要帶來額外的開銷,程序的可重用性差。
由於圖形用戶界面的應用,程序運行由順序運行演變為事件驅動,使得軟體使用起來越來越方便,但開發起來卻越來越困難,對這種軟體的功能很難用過程來描述和實現,使用面向過程的方法來開發和維護都將非常困難。

1-4 什麼是對象?什麼是面向對象方法?這種方法有哪些特點?

解:
從一般意義上講,對象是現實世界中一個實際存在的事物,它可以是有形的,也可以是無形的。對象是構成世界的一個獨立單位,它具有自己的靜態特徵和動態特徵。面向對象方法中的對象,是系統中用來描述客觀事物的一個實體,它是用來構成系統的一個基本單位,由一組屬性和一組行為構成。
面向對象的方法將數據及對數據的操作方法放在一起,作為一個相互依存、不可分離的整體--對象。對同類型對象抽象出其共性,形成類。類中的大多數數據,只能用本類的方法進行處理。類通過一個簡單的外部介面,與外界發生關系,對象與對象之間通過消息進行通訊。這樣,程序模塊間的關系更為簡單,程序模塊的獨立性、數據的安全性就有了良好的保障。通過實現繼承與多態性,還可以大大提高程序的可重用性,使得軟體的開發和維護都更為方便。
面向對象方法所強調的基本原則,就是直接面對客觀存在的事物來進行軟體開發,將人們在日常生活中習慣的思維方式和表達方式應用在軟體開發中,使軟體開發從過分專業化的方法、規則和技巧中回到客觀世界,回到人們通常的思維。

1-5 什麼叫做封裝?

解:
封裝是面向對象方法的一個重要原則,就是把對象的屬性和服務結合成一個獨立的系統單位,並盡可能隱蔽對象的內部細節。

1-6 面向對象的軟體工程包括哪些主要內容?

解:
面向對象的軟體工程是面向對象方法在軟體工程領域的全面應用,它包括面向對象的分析(OOA)、面向對象的設計(OOD)、面向對象的編程(OOP)、面向對象的測試(OOT)和面向對象的軟體維護(OOSM)等主要內容。

1-7 簡述計算機內部的信息可分為幾類?

解:
計算機內部的信息可以分成控制信息和數據信息二大類;控制信息可分為指令和控制字兩類;數據信息可分為數值信息和非數值信息兩類。

1-8 什麼叫二進制?使用二進制有何優點和缺點?

解:
二進制是基數為2,每位的權是以2 為底的冪的進制,遵循逢二進一原則,基本符號為0和1。採用二進制碼表示信息,有如下幾個優點:1.易於物理實現;2.二進制數運算簡單;3.機器可靠性高;4.通用性強。其缺點是它表示數的容量較小,表示同一個數,二進制較其他進制需要更多的位數。

1-9 請將以下十進制數值轉換為二進制和十六進制補碼:
(1)2 (2)9 (3)93
(4)-32 (5)65535 (6)-1

解:
(1) (2)10 = (10)2 = (2)16
(2) (9)10 = (1001)2 = (9)16
(3) (93)10 = (1011101)2 = (5D)16
(4) (-32)10 = (11100000)2 = (E0)16
(5) (65535)10 = (11111111 11111111)2 = (FFFF)16
(6) (-1)10 = (11111111 11111111)2 = (FFFF)16

1-10 請將以下數值轉換為十進制:
(1)(1010)2 (2)(10001111)2 (3)(01011111 11000011)2
(4)(7F)16 (5)(2D3E)16 (6)(F10E)16

解:
(1)(1010)2 = (10)10
(2)(10001111)2 = (143)10
(3)(01011111 11000011)2 = (24515)10
(4)(7F)16 = (127)10
(5)(2D3E)16 = (11582)10
(6)(F10E)16 = (61710)10

1-11 簡要比較原碼、反碼、補碼等幾種編碼方法。
解:
原碼:將符號位數字化為 0 或 1,數的絕對值與符號一起編碼,即所謂"符號——絕對值表示"的編碼。
正數的反碼和補碼與原碼表示相同。
負數的反碼與原碼有如下關系:
符號位相同(仍用1表示),其餘各位取反(0變1,1變0)。
補碼由該數反碼的最末位加1求得。

第 二 章 C++簡單程序設計

2-1 C++語言有那些主要特點和優點?

解:
C++語言的主要特點表現在兩個方面,一是全面兼容C,二是支持面向對象的方法。C++是一個更好的C,它保持了C的簡潔、高效、接近匯編語言、具有良好的可讀性和可移植性等特點,對C的類型系統進行了改革和擴充,因此C++比C更安全,C++的編譯系統能檢查出更多的類型錯誤。 C++語言最重要的特點是支持面向對象。

2-2 下列標識符哪些是合法的?
Program, -page, _lock, test2, 3in1, @mail, A_B_C_D

解:
Program, _lock, test2, A_B_C_D是合法的標識符,其它的不是。

2-3 例2.1中每條語句的作用是什麼?
#include <iostream.h>
void main(void)
{
cout<<"Hello!\n";
cout<<"Welcome to c++!\n";
}

解:
#include <iostream.h> //指示編譯器將文件iostream.h中的代碼
//嵌入到該程序中該指令所在的地方
void main() //主函數名,void 表示函數沒有返回值
{ //函數體標志
cout<<"Hello!\n"; //輸出字元串Hello!到標准輸出設備(顯示器)上。
cout<<"Welcome to c++!\n"; //輸出字元串Welcome to c++!
}
在屏幕輸出如下:
Hello!
Welcome to c++!

2-4 使用關鍵字const而不是#define語句的好處有哪些?

解:
const定義的常量是有類型的,所以在使用它們時編譯器可以查錯;而且,這些變數在調試時仍然是可見的。

2-5 請寫出C++語句聲明一個常量PI,值為3.1416;再聲明一個浮點型變數a,把PI的值賦給a。

解:
const float PI = 3.1416;
float a = PI;

2-6 在下面的枚舉類型中,Blue的值是多少?
enum COLOR ;

解:
Blue = 102

2-7 注釋有什麼作用?C++中有哪幾種注釋的方法?他們之間有什麼區別?

解:
注釋在程序中的作用是對程序進行註解和說明,以便於閱讀。編譯系統在對源程序進行編譯時不理會注釋部分,因此注釋對於程序的功能實現不起任何作用。而且由於編譯時忽略注釋部分,所以注釋內容不會增加最終產生的可執行程序的大小。適當地使用注釋,能夠提高程序的可讀性。在C++中,有兩種給出注釋的方法:一種是延用C語言方法,使用"/*"和"*/"括起注釋文字。另一種方法是使用"//",從"//"開始,直到它所在行的行尾,所有字元都被作為注釋處理。

2-8 什麼叫做表達式?x = 5 + 7是一個表達式嗎?它的值是多少?

解:
任何一個用於計算值的公式都可稱為表達式。x = 5 + 7是一個表達式,它的值為12。

2-9 下列表達式的值是多少?
1. 201 / 4
2. 201 % 4
3. 201 / 4.0

解:
1. 50
2. 1
3. 50.25

2-10 執行完下列語句後,a、b、c三個變數的值為多少?
a = 30;
b = a++;
c = ++a;

解:
a:32 ; b:30 ; c:32;

2-11 在一個for循環中,可以初始化多個變數嗎?如何實現?

解:
在for循環設置條件的第一個";"前,用,分隔不同的賦值表達式。
例如:
for (x = 0, y = 10; x < 100; x++, y++)

2-12 執行完下列語句後,n的值為多少?
int n;
for (n = 0; n < 100; n++)

『柒』 deitel大學c語言教程答案

是這個嗎

『捌』 《c大學教程》第五版 習題答案 為提供者追加200分

第四版的答案:

http://www.rayfile.com/zh-cn/files/c4d7ca40-8d1e-11dd-9634-0019d11a795f/

『玖』 求《C 大學教程》/《C how to program》第5版 課後練習答案

《c大學教程 (Deitle 著) 電子工業出版社 課後答案》
是不是這個?

『拾』 c/c++程序設計基礎教程課後答案(清華大學出版社)

譚浩強的都很好

熱點內容
四川農業大學申請考核博士 發布:2025-10-20 08:58:11 瀏覽:981
福田雷沃重工本科生待遇怎麼樣 發布:2025-10-20 08:53:49 瀏覽:575
華為要本科生嗎 發布:2025-10-20 08:25:41 瀏覽:550
2008年青島本科生工資 發布:2025-10-20 08:04:24 瀏覽:444
東北大學藝術考研 發布:2025-10-20 07:38:35 瀏覽:299
我的大學生活txt 發布:2025-10-20 07:35:28 瀏覽:25
人民大學外語系考研 發布:2025-10-20 07:31:12 瀏覽:894
上海交通大學考研輔導班 發布:2025-10-20 07:24:54 瀏覽:420
華中農業大學細胞生物學考研群 發布:2025-10-20 07:09:36 瀏覽:558
南京大學2016考研線 發布:2025-10-20 06:43:12 瀏覽:930