c++primerplus中文版第六版源代码.docx
- 文档编号:27684754
- 上传时间:2023-07-04
- 格式:DOCX
- 页数:53
- 大小:20.04KB
c++primerplus中文版第六版源代码.docx
《c++primerplus中文版第六版源代码.docx》由会员分享,可在线阅读,更多相关《c++primerplus中文版第六版源代码.docx(53页珍藏版)》请在冰豆网上搜索。
c++primerplus中文版第六版源代码
C++primerplus中文版第六版源代码
第二章到第四章,后续继续更新⋯⋯⋯
第二章
1:
#include
voidmain()
{
usingnamespacestd;
intcarrots;
carrots=25;
cout<<"Ihave";
cout< cout<<"carrots."; cout< carrots=carrots-1; cout<<"Crunch,crunch.NowIhave"< } 2: #include intstonetolb(int); intmain() { usingnamespacestd; intstone; cout<<"Entertheweightinstone: "; cin>>stone; intpounds=stonetolb(stone); cout< cout< return0; } intstonetolb(intsts) { return14*sts; } 3: #include voidmain() { usingnamespacestd; intcarrots; carrots=25; cout<<"Howmanycarrotsdoyouhave? "< cout<<"Herearetwomore."; carrots=carrots+2; cout<<"Nowyouhave"< //下两行专门测试cin.get() cin.get(); cin.get(); } 4: #include usingnamespacestd; voidmain() { cout<<"ComeupandC++mesometime."; cout< cout<<"Youwon'tregretit! "< } 5#include voidsimon(int); intmain() { usingnamespacestd; simon(3); cout<<"Pickaninteger: "; intcount; cin>>count; simon(count); cout<<"Done! "< return0; } voidsimon(intn) { usingnamespacestd; cout<<"Simonsaystouchyourtoes"< } 6: #include #include voidmain() { usingnamespacestd; doublearea; cout<<"Enterthefloorarae,insquarefeet,ofyourhome: "; cin>>area; doubleside; side=sqrt(area); cout<<"That'stheequivalentofasquare"< cout<<"Howfascinating! "< } 第三章 1: #include #include usingnamespacestd; intmain() { intn_int=INT_MAX; shortn_short=SHRT_MAX; longn_long=LONG_MAX; cout<<"intis"< cout<<"Maximumvalues: "< cout<<"int: "< cout<<"short: "< cout<<"long: "< cout<<"Minimumintvalue="< } 2: #include #include #defineZERO0 usingnamespacestd; intmain() { shortsam=SHRT_MAX; unsignedshortsue=sam; cout<<"samhas"< <<"Add$1toeachaccount."< sue=sue+1; cout<<"Samhas"< cout<<"dollarsdeposited.\npoorsam! "< sam=ZERO; sue=ZERO; cout<<"samhas"< cout<<"Take$1fromeachaccount."< sam=sam-1; sue=sue-1; cout<<"samhas"< cout<<"dollarsdeposited."< "< } 3: #include usingnamespacestd; voidmain() { intchest=42; intwaist=0x42; intinseam=042; cout<<"Monsieurcutsastrikingfigure! \n";cout<<"chest="< } 4: #include usingnamespacestd; voidmain() { intchest=42; intwaist=42; intinseam=42; cout<<"Monsieurcutsastrikingfigure! \n";cout<<"chest="< cout< cout<<"waist="< cout<<"inseam="< } 5: #include usingnamespacestd; voidmain() { cout<<"\aoperation\"HyperHype\"isnowactivated! \n";cout<<"Enteryouragentcode: __________\b\b\b\b\b\b\b\b";longcode; cin>>code; cout<<"\aYouentered"< proceedwithplanz3! \n"; } 6: #include usingnamespacestd; voidmain() { charch; cout<<"Enteracharacter: "< cin>>ch; cout<<"Hola! "; cout<<"Thankyouforthe"< } 7: #include usingnamespacestd; voidmain() { charch='M'; inti=ch; cout<<"TheASCIIcodefor"< cout<<"Addonetothecharactercode: "< ch=ch+1; i=ch; cout<<"TheASCIIcodefor"< cout<<"Displayingcharchusingcout.put(ch): ";cout.put(ch); cout.put('! '); cout< } 8: #include usingnamespacestd; voidmain() { cout.setf(ios_base: : fixed,ios_base: : floatfield);//控制cout显示的形式floattub=10.0/3.0; doublemint=10.0/3.0; constfloatmillion=1.0e6;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- primerplus 中文版 第六 源代码