最新c++程序设计谭浩强课后习题答案完整版资料.docx

上传人:b****3 文档编号:5550981 上传时间:2023-05-08 格式:DOCX 页数:63 大小:28.95KB
下载 相关 举报
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第1页
第1页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第2页
第2页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第3页
第3页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第4页
第4页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第5页
第5页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第6页
第6页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第7页
第7页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第8页
第8页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第9页
第9页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第10页
第10页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第11页
第11页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第12页
第12页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第13页
第13页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第14页
第14页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第15页
第15页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第16页
第16页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第17页
第17页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第18页
第18页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第19页
第19页 / 共63页
最新c++程序设计谭浩强课后习题答案完整版资料.docx_第20页
第20页 / 共63页
亲,该文档总共63页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

最新c++程序设计谭浩强课后习题答案完整版资料.docx

《最新c++程序设计谭浩强课后习题答案完整版资料.docx》由会员分享,可在线阅读,更多相关《最新c++程序设计谭浩强课后习题答案完整版资料.docx(63页珍藏版)》请在冰点文库上搜索。

最新c++程序设计谭浩强课后习题答案完整版资料.docx

最新c++程序设计谭浩强课后习题答案完整版资料

因此不难看出,自制饰品在校园里也大有市场所在。

对于那些走在流行前端的女生来说,〝捕捉〞新事物便〝捕捉〞到了时尚与个性。

(1)专业知识限制

据调查,大学生对此类消费的态度是:

手工艺制品消费比“负债”消费更得人心。

标题:

手工制作坊2004年3月18日

“碧芝”的成功归于他的唯一,这独一无二的物品就吸引了各种女性的眼光。

7、你喜欢哪一类型的DIY手工艺制品?

3.www。

oh/ov。

com/teach/student/shougong/

世界上的每一个国家和民族都有自己的饰品文化,将这些饰品汇集到一起再进行新的组合,便可以无穷繁衍下去,满足每一个人不同的个性需求。

2.www。

cer。

net/artide/2003082213089728。

shtml。

而手工艺制品是一种价格适中,不仅能锻炼同学们的动手能力,同时在制作过程中也能体会一下我国传统工艺的文化。

无论是送给朋友还是亲人都能让人体会到一份浓厚的情谊。

它的价值是不用金钱去估价而是用你一颗真诚而又温暖的心去体会的。

更能让学生家长所接受。

第八章

#includeusingnamespacestd;classTime

{public:

//成员改为公用的

inthour;intminute;intsec;};

Timet;

voidset_time(void)//在main函数之前定义

{cin>>t.hour;cin>>t.minute;cin>>t.sec;

}

voidshow_time(void)//在main函数之前定义

{

cout<

"<

"<

}

intmain(){set_time();show_time();return0;

}

8.2题

#includeusingnamespacestd;classTime

{public:

voidset_time(void){cin>>hour;cin>>minute;cin>>sec;}voidshow_time(void)

{cout<

"<

"<

private:

inthour;

intminute;intsec;

};

Timet;intmain()

{

t.set_time();

t.show_time();return0;

}

8.3题

#includeusingnamespacestd;classTime

{public:

voidset_time(void);voidshow_time(void);private:

inthour;intminute;

intsec;

};voidTime:

:

set_time(void){cin>>hour;cin>>minute;cin>>sec;

}voidTime:

:

show_time(void)

{cout<

"<

"<

Timet;intmain(){t.set_time();

t.show_time();return0;

}

8.4题

//xt8-4.h(student.h)classStudent

{public:

voiddisplay();voidset_value();private:

intnum;charname[20];charsex;

};

8.4题

//xt8-4-1.cpp(main.cpp)#includeusingnamespacestd;#include"xt8-4.h"intmain(){Studentstud;stud.set_value();stud.display();return0;

}

8.4题另一解

//xt8-4-2.cpp(即student.cpp)#include"xt8-4.h"//在此文件中进行

函数的定义

#includeusingnamespacestd;//不要漏写此行voidStudent:

:

display(){cout<<"num:

"<

"<

"<

}

voidStudent:

:

set_value()

{cin>>num;cin>>name;cin>>sex;

}

8.5题

//xt8-5.h(arraymax.h)classArray_max{public:

voidset_value();voidmax_value();voidshow_value();private:

intarray[10];intmax;

};

8.5题

//xt8-5-1.cpp(file1.cpp)

#include#include"xt8-5.h"intmain()

{Array_maxarrmax;arrmax.set_value();arrmax.max_value();arrmax.show_value();return0;

}

8.5题

//xt8-5-2.cpp(arraymax.cpp)#includeusingnamespacestd;#include"xt8-5.h"

voidArray_max:

:

set_value()

{inti;

for(i=0;i<10;i++)cin>>array[i];

}

voidArray_max:

:

max_value()

{inti;

max=array[0];for(i=1;i<10;i++)if(array[i]>max)max=array[i];

}

voidArray_max:

:

show_value()

{cout<<"max="<

}

8.6题

#includeusingnamespacestd;classBox{public:

voidget_value();floatvolume();voiddisplay();public:

floatlengh;floatwidth;floatheight;

};

voidBox:

:

get_value()

{cout<<"pleaseinputlengh,width,height:

";cin>>lengh;cin>>width;cin>>height;

}

floatBox:

:

volume()

{return(lengh*width*height);}

voidBox:

:

display()

{cout<

intmain()

{Boxbox1,box2,box3;box1.get_value();cout<<"volmueofbax1is";box1.display();box2.get_value();cout<<"volmueofbax2is";box2.display();box3.get_value();cout<<"volmueofbax3is";box3.display();return0;

}

8.6题另一解

#includeusingnamespacestd;classBox

{public:

voidget_value();voidvolume();voiddisplay();public:

floatlengh;floatwidth;floatheight;floatvol;

};

voidBox:

:

get_value()

{cout<<"pleaseinputlengh,width,height:

";cin>>lengh;cin>>width;cin>>height;

}

voidBox:

:

volume()

{vol=lengh*width*height;}

voidBox:

:

display()

{cout<

intmain()

{Boxbox1,box2,box3;

box1.get_value();box1.volume();cout<<"volmueofbax1is";box1.display();box2.get_value();box2.volume();cout<<"volmueofbax2is";box2.display();box3.get_value();box3.volume();cout<<"volmueofbax3is";box3.display();return0;

}

9.2题

#includeusingnamespacestd;classDate

{public:

Date(int,int,int);

Date(int,int);

Date(int);Date();voiddisplay();private:

intmonth;intday;intyear;

};

Date:

:

Date(intm,intd,inty):

month(m),day(d),year(y)

{}

Date:

:

Date(intm,intd):

month(m),day(d)

{year=2005;}

Date:

:

Date(intm):

month(m)

{day=1;year=2005;

}

Date:

:

Date()

{month=1;

day=1;year=2005;

}

voidDate:

:

display()

{cout<

intmain()

{

Dated1(10,13,2005);

Dated2(12,30);

Dated3(10);Dated4;d1.display();d2.display();d3.display();d4.display();return0;

}

9.3题

#include

usingnamespacestd;classDate

{public:

Date(int=1,int=1,int=2005);voiddisplay();private:

intmonth;intday;intyear;

};

Date:

:

Date(intm,intd,inty):

month(m),day(d),year(y)

{}

voidDate:

:

display()

{cout<

intmain()

{

Dated1(10,13,2005);

Dated2(12,30);

Dated3(10);

Dated4;d1.display();d2.display();d3.display();d4.display();return0;

}

9.4题

#includeusingnamespacestd;classStudent

{public:

Student(intn,floats):

num(n),score(s){}voiddisplay();private:

intnum;floatscore;

};

voidStudent:

:

display()

{cout<

intmain()

{Studentstud[5]={

Student(101,78.5),Student(102,85.5),Student(103,98.5),

Student(104,100.0),Student(105,95.5)};Student*p=stud;for(inti=0;i<=2;p=p+2,i++)p->display();return0;

}

9.5题

#includeusingnamespacestd;classStudent

{public:

Student(intn,floats):

num(n),score(s){}intnum;floatscore;

};

voidmain()

{Studentstud[5]={

Student(101,78.5),Student(102,85.5),Student(103,98.5),Student(104,100.0),Student(105,95.5)};voidmax(Student*);Student*p=&stud[0];max(p);

}

voidmax(Student*arr){floatmax_score=arr[0].score;intk=0;for(inti=1;i<5;i++)if(arr[i].score>max_score){max_score=arr[i].score;k=i;}cout<

}

9.6题

#includeusingnamespacestd;classStudent

{public:

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats){num=n;score=s;}voiddisplay(){cout<

intnum;floatscore;

};

intmain()

{Studentstud(101,78.5);stud.display();stud.change(101,80.5);stud.display();return0;

}

9.7题

#include

usingnamespacestd;classStudent

{public:

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats){num=n;score=s;}voiddisplay(){cout<

//可改为:

voiddisplay()const{cout<

"<

intnum;floatscore;

};

intmain()

{constStudentstud(101,78.5);stud.display();//stud.change(101,80.5);stud.display();return0;

}

9.7题另一解

#includeusingnamespacestd;classStudent

{public:

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats)const{num=n;score=s;}voiddisplay()const{cout<

mutableintnum;mutablefloatscore;

};

intmain()

{constStudentstud(101,78.5);stud.display();stud.change(101,80.5);stud.display();return0;

}

9.7题另一解

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats){num=n;score=s;}voiddisplay(){cout<

intnum;floatscore;

};

intmain()

{Studentstud(101,78.5);Student*p=&stud;p->display();p->change(101,80.5);p->display();return0;

}

A

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats){num=n;score=s;}voiddisplay(){cout<

mutableintnum;mutablefloatscore;

};

intmain()

{Studentstud(101,78.5);constStudent*p=&stud;p->display();p->change(101,80.5);p->display();return0;

}

B

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats){num=n;score=s;}voiddisplay()const{cout<

intnum;floatscore;

};

intmain()

{Studentstud(101,78.5);constStudent*p=&stud;p->display();stud.change(101,80.5);p->display();return0;

}

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats){num=n;score=s;}voiddisplay(){cout<

intnum;floatscore;

};

intmain()

{Studentstud(101,78.5);Student*constp=&stud;p->display();p->change(101,80.5);p->display();return0;

}

9.8题

Student(intn,floats):

num(n),score(s){}voidchange(intn,floats){num=n;score=s;}voiddisplay(){cout<

intnum;floatscore;

};

intmain()

{Studentstud(101,78.5);voidfun(Student&);fun(stud);return0;

}

voidfun(Student&stu){stu.display();stu.change(101,80.5);stu.display();

}

9.9题

#includeusingnamespacestd;classProduct

{public:

Product(intn,intq,float

p):

num(n),quantity(q),price(p){};voidtotal();staticfloataverage();staticvoiddisplay();

private:

intnum;intquantity;floatprice;staticfloatdiscount;staticfloatsum;staticintn;

};

voidProduct:

:

total()

{floatrate=1.0;if(quantity>10)rate=0.98*rate;sum=sum+quantity*price*rate*(1-discount);n=n+quantity;

}

voidProduct:

:

display(){cout<

}

floatProduct:

:

average()

{return(sum/n);}

floatProduct:

:

discount=0.05;floatProduct:

:

sum=0;intProduct:

:

n=0;

intmain()

{

ProductProd[3]={Product(101,5,23.5),Product(102,12,24.56),Product(103,

100,21.5)};for(inti=0;i<3;i++)Prod[i].tota

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2