当前位置:首页 » 招生排名 » c大学基础教程第五版答案

c大学基础教程第五版答案

发布时间: 2022-03-11 14:27:28

㈠ 求《C++大学教程》(国外Harvey M.Deitel的第五版电子工业出版)社课后习题答案,我邮箱:[email protected]

laile

㈡ 想要学习C++ 有一些C基础 不知道《C++大学基础教程》第五版 适合不适合入门 请大虾指导

1.把C++当成一门新的语言学习(和C没啥关系!真的。);
2.看《Thinking In C++》,不要看《C++变成死相》;
3.看《The C++ Programming Language》和《Inside The C++ Object Model》,不要因为他们很难而我们自己是初学者所以就不看;
4.不要被VC、BCB、BC、MC、TC等词汇所迷惑——他们都是集成开发环境,而我们要学的是一门语言;
5.不要放过任何一个看上去很简单的小编程问题——他们往往并不那么简单,或者可以引伸出很多知识点;
6.会用Visual C++,并不说明你会C++;
7.学class并不难,template、STL、generic programming也不过如此——难的是长期坚持实践和不遗余力的博览群书;
8.如果不是天才的话,想学编程就不要想玩游戏——你以为你做到了,其实你的C++水平并没有和你通关的能力一起变高——其实可以时刻记住:学C++是为了编游戏的;
9.看Visual C++的书,是学不了C++语言的;
10.浮躁的人容易说:XX语言不行了,应该学YY;——是你自己不行了吧!?
11.浮躁的人容易问:我到底该学什么;——别问,学就对了;
12.浮躁的人容易问:XX有钱途吗;——建议你去抢银行;
13.浮躁的人容易说:我要中文版!我英文不行!——不行?学呀!
14.浮躁的人容易问:XX和YY哪个好;——告诉你吧,都好——只要你学就行;
15.浮躁的人分两种:a)只观望而不学的人;b)只学而不坚持的人;
16.把时髦的技术挂在嘴边,还不如把过时的技术记在心里;
17.C++不仅仅是支持面向对象的程序设计语言;
18.学习编程最好的方法之一就是阅读源代码;
19.在任何时刻都不要认为自己手中的书已经足够了;
20.请阅读《The Standard C++ Bible》(中文版:标准C++宝典),掌握C++标准;
21.看得懂的书,请仔细看;看不懂的书,请硬着头皮看;
22.别指望看第一遍书就能记住和掌握什么——请看第二遍、第三遍;
23.请看《Effective C++》和《More Effective C++》以及《Exceptional C++》;
24.不要停留在集成开发环境的摇篮上,要学会控制集成开发环境,还要学会用命令行方式处理程序;
25.和别人一起讨论有意义的C++知识点,而不是争吵XX行不行或者YY与ZZ哪个好;
26.请看《程序设计实践》,并严格的按照其要求去做;
27.不要因为C和C++中有一些语法和关键字看上去相同,就认为它们的意义和作用完全一样;
28.C++绝不是所谓的C的“扩充”——如果C++一开始就起名叫Z语言,你一定不会把C和Z语言联系得那么紧密;
29.请不要认为学过XX语言再改学C++会有什么问题——你只不过又在学一门全新的语言而已;
30.读完了《Inside The C++ Object Model》以后再来认定自己是不是已经学会了C++;
31.学习编程的秘诀是:编程,编程,再编程;
32.请留意下列书籍:《C++面向对象高效编程(C++ Effective Object-Oriented Software Construction)》《面向对象软件构造(Object-Oriented Software Construction)》《设计模式(Design Patterns)》《The Art of Computer Programming》;
33.记住:面向对象技术不只是C++专有的;
34.请把书上的程序例子亲手输入到电脑上实践,即使配套光盘中有源代码;
35.把在书中看到的有意义的例子扩充;
36.请重视C++中的异常处理技术,并将其切实的运用到自己的程序中;
37.经常回顾自己以前写过的程序,并尝试重写,把自己学到的新知识运用进去;
38.不要漏掉书中任何一个练习题——请全部做完并记录下解题思路;
39.C++语言和C++的集成开发环境要同时学习和掌握;
40.既然决定了学C++,就请坚持学下去,因为学习程序设计语言的目的是掌握程序设计技术,而程序设计技术是跨语言的;
41.就让C++语言的各种平台和开发环境去激烈的竞争吧,我们要以学习C++语言本身为主;
42.当你写C++程序写到一半却发现自己用的方法很拙劣时,请不要马上停手;请尽快将余下的部分粗略的完成以保证这个设计的完整性,然后分析自己的错误并重新设计和编写(参见43);
43.别心急,设计C++的class确实不容易;自己程序中的class和自己的class设计水平是在不断的编程实践中完善和发展的;
44.决不要因为程序“很小”就不遵循某些你不熟练的规则——好习惯是培养出来的,而不是一次记住的;
45.每学到一个C++难点的时候,尝试着对别人讲解这个知识点并让他理解——你能讲清楚才说明你真的理解了;
46.记录下在和别人交流时发现的自己忽视或不理解的知识点;
47.请不断的对自己写的程序提出更高的要求,哪怕你的程序版本号会变成Version 100.XX;
48.保存好你写过的所有的程序——那是你最好的积累之一;
49.请不要做浮躁的人;
50.请热爱C++!

---------------------------------------------以上是别人的建议,作以补充------------------------------------
第一本:《Thinking In C++》 转变到C++的模式
然后:《The C++ Programming Language》 C++之父的经典之作,无可替代
《Inside The C++ Object Model》 需要一定的基础,先过一遍,对程序有一定理解了需要再一点点的慢慢看。
看 《unix环境高级编程》《unix网络编程 卷一》 不论你是windows平台还是unix平台,这两本都是很有益处的,不过价格不菲,实在不舍得的话,建议看第二本网络编程
期间可以看一些小书,关于C++的 《effective C++》 《more effective c++》 等等乱七八糟的也无所谓了。 期间会对C++有深入理解。可以选自己觉得不错的书一遍遍的看。

㈢ 《c大学教程》第五版 习题答案 为提供者追加200分

第四版的答案:

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

㈣ 谁有山东大学出版社《量子力学基础教程》陈鄂生第五版的答案啊实在不行其他版也行啊。

国内但言量子力学教材,则称曾谨言、钱伯初、周世勋,很少有人在意陈鄂生先生这本小蓝书的.我却觉得这本书写的流畅疏简,脉络清晰,十分适合做量子力学的入门教材.曾谨言先生的书,内容庞杂,讲授方法,说真的,但求全面而不在意是否逻辑清晰.有时候还会有错误,尤其是在第二卷.如果在有了一定基础之后,拿来当工具书,还是可以的.初学就看这个,很容易被里面众多公式、方程吓到.陈先生的这本书,在量子力学五大基本假设、算符方法、角动量理论、表象变换理论、自旋引入、微绕理论以及散射理论方面的讲解都很清简,在不忽略物理的情况下,尽量把数学做到最少.有时候过分的加入数学,反而会使物理在公式方程的笼罩之下变得模糊.陈先生的书,用简单的例子,就可以把量子力学的基本原理、基本方法讲的很清楚.本书有数量适中的习题,大都是出自于这些年来的考研题目,很经典.本书还有一本配套的习题解答,全是历年各高校、研究所考研题目的汇编集解,应该是考研不可缺少的参考书.如果能够把那本参考书中的题目,都能亲手算一遍的话,就会发现原来理解不对、或者没有理解的地方慢慢的便理解了.不管你学量子力学的时候用的是谁的教材,这本书配套的习题集,还是非常值得通做一遍的,就算不是为了考研,而是为了理解量子力学,也是值得的.

㈤ 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++)

㈥ 您好,《c++大学基础教程第五版》89页建立invoice类的题目做错,自学中,求助!

主程序中 main()
中有全角的,和;
应为:
int main ()
{
Invoice Invoice1( "89757", "huawei honor",1000, 1999 );
Invoice1.getInvoiceAmount();

return 0; /**/
}

㈦ C++大学教程(第5版)课后答案

http://www.gougou.com/search?search=c%2B%2B%E8%AF%BE%E5%90%8E%E7%AD%94%E6%A1%88&restype=-1&id=10000001&ty=0&pattern=0
自己下载吧,有你需要的。

㈧ 求《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 how to program》第5版 课后练习答案

《c大学教程 (Deitle 著) 电子工业出版社 课后答案》
是不是这个?

㈩ C语言程序设计第五版课后习题答案在哪能找到

你可以去看下(答案管家)wx公-众-号,里面就有这本。

热点内容
四川农业大学申请考核博士 发布: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