c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx

上传人:b****6 文档编号:8326878 上传时间:2023-05-11 格式:DOCX 页数:27 大小:19.79KB
下载 相关 举报
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第1页
第1页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第2页
第2页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第3页
第3页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第4页
第4页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第5页
第5页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第6页
第6页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第7页
第7页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第8页
第8页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第9页
第9页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第10页
第10页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第11页
第11页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第12页
第12页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第13页
第13页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第14页
第14页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第15页
第15页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第16页
第16页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第17页
第17页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第18页
第18页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第19页
第19页 / 共27页
c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx_第20页
第20页 / 共27页
亲,该文档总共27页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx

《c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx(27页珍藏版)》请在冰点文库上搜索。

c++ primer plus 中文版 第六版源代码Word文档下载推荐.docx

stone="

pounds<

pounds."

return0;

intstonetolb(intsts)

return14*sts;

3:

Howmanycarrotsdoyouhave?

Herearetwomore."

carrots=carrots+2;

Nowyouhave"

carrots."

//下两行专门测试cin.get()

cin.get();

4:

usingnamespacestd;

ComeupandC++mesometime."

Youwon'

tregretit!

5#include<

voidsimon(int);

simon(3);

Pickaninteger:

intcount;

count;

simon(count);

Done!

voidsimon(intn)

Simonsaystouchyourtoes"

n<

times."

6:

cmath>

doublearea;

Enterthefloorarae,insquarefeet,ofyourhome:

area;

doubleside;

side=sqrt(area);

That'

stheequivalentofasquare"

side

<

feettotheside."

Howfascinating!

第三章

climits>

intn_int=INT_MAX;

shortn_short=SHRT_MAX;

longn_long=LONG_MAX;

intis"

sizeof(int)<

bytes."

shortis"

sizeofn_short<

longis"

sizeofn_long<

endl<

Maximumvalues:

int:

n_int<

short:

n_short<

long:

n_long<

Minimumintvalue="

INT_MIN<

Bitsperbyts="

CHAR_BIT<

#defineZERO0

shortsam=SHRT_MAX;

unsignedshortsue=sam;

samhas"

sam<

dollarsandsuehas"

sue;

dollarsdeposited."

endl

Add$1toeachaccount."

Now"

sam=sam+1;

sue=sue+1;

Samhas"

dollarsdeposited.\npoorsam!

sam=ZERO;

sue=ZERO;

Take$1fromeachaccount."

sam=sam-1;

sue=sue-1;

dolarsandsuehas"

Luckysue!

intchest=42;

intwaist=0x42;

intinseam=042;

Monsieurcutsastrikingfigure!

\n"

chest="

chest<

(42indecimal)\n"

waist="

waist<

(0x42inhex)\n"

inseam="

inseam<

(042inoctal)\n"

intwaist=42;

intinseam=42;

(decimalfor42)"

hex;

(hexadecimalfor42)"

oct;

(octalfor42)\n"

5:

\aoperation\"

HyperHype\"

isnowactivated!

Enteryouragentcode:

__________\b\b\b\b\b\b\b\b"

longcode;

code;

\aYouentered"

code<

...\n"

\acodeverified!

proceedwithplanz3!

charch;

Enteracharacter:

ch;

Hola!

Thankyouforthe"

ch<

character."

7:

charch='

M'

inti=ch;

TheASCIIcodefor"

is"

i<

Addonetothecharactercode:

ch=ch+1;

i=ch;

Displayingcharchusingcout.put(ch):

cout.put(ch);

cout.put('

!

'

);

Done"

8:

cout.setf(ios_base:

:

fixed,ios_base:

floatfield);

//控制cout显示的形式

floattub=10.0/3.0;

doublemint=10.0/3.0;

constfloatmillion=1.0e6;

tub="

tub;

amilliontubs="

million*tub;

\nandtenmilliontubs="

10*million*tub<

mint="

mint<

andamillionmints="

million*mint<

9:

floata=2.34e+22f;

floatb=a+1.0f;

a="

a<

b-a="

b-a<

10:

doublehats,heads;

//或者是float

Enteranumber:

hats;

Enteranothernumber:

heads;

hats="

hats<

heads="

heads<

hats+heads="

hats+heads<

hats-heads="

hats-heads<

hats*heads="

hats*heads<

hats/heads="

hats/heads<

11:

Integerdivision:

9/5="

9/5<

Floating-pointdivision:

9.0/5.0="

9.0/5.0<

Mixeddivision:

9.0/5="

9.0/5<

doubleconstants:

1.e7/9.0="

1.e7/9.0<

floatconstants:

1.e7f/9.0f="

1.e7f/9.0f<

12:

constintLbs_per_stn=14;

intlbs;

Enteryourweightinpounds:

lbs;

intstone=lbs/Lbs_per_stn;

intpounds=lbs%Lbs_per_stn;

lbs<

poundsare"

stone

stone,"

pound(s).\n"

13:

floattree=3;

intguess(3.9832);

intdebt=7.2E12;

tree="

tree<

guess="

guess<

debt="

debt<

14:

intauks,bats,coots;

auks=19.99+11.99;

bats=(int)19.99+(int)11.99;

coots=int(19.99)+int(11.99);

auks="

auks<

bats="

bats;

coots="

coots<

Z'

Thecodefor"

int(ch)<

Yes,thecodeis"

//cout<

statiic_cast<

int>

(ch)<

第四章

intyams[3];

yams[0]=7;

yams[1]=8;

yams[2]=6;

intyamcosts[3]={20,30,5};

Totalyams="

yams[0]+yams[1]+yams[2]<

Thepackagewith"

yams[1]<

yamscosts"

yamcosts[1]<

centsperyam.\n"

inttotal=yams[0]*yamcosts[0]+yams[1]*yamcosts[1];

total=total+yams[2]*yamcosts[2];

Thetotalyamexpenseis"

total<

cents.\n"

\nSizeofyamsarray="

sizeofyams;

bytes.\n"

Sizeofoneelement="

sizeofyams[0];

constintsize=15;

charname1[size];

charname2[size]="

C++owboy"

Howdy!

I'

m"

name2;

what'

syourname?

name1;

Well,"

name1<

yournamehas"

strlen(name1)<

lettersandisstored\n"

inanarrayof"

sizeofname1<

Yourinitialis"

name1[0]<

.\n"

name2[3]='

\0'

Herearethefirst3charchtersofmyname:

name2<

constintarsize=20;

charname[arsize];

chardessert[arsize];

Enteryourname:

name;

Enteryourfavoritedessert:

dessert;

Ihavesomedelicious"

foryou,"

name<

cin.getline(name,arsize);

cin.getline(dessert,arsize);

cin.get(name,arsize).get();

cin.get(dessert,arsize);

string>

charcharr1[20];

charcharr2[20]="

jaguar"

stringstr1;

stringstr2="

panther"

Enterakindoffeline:

charr1;

Enteranotherkindoffeline:

str1;

Herearesomefelines:

charr1<

charr2<

str1<

str2

Thethirdletterin"

charr2[2]<

str2<

str2[2]<

strings1="

penguin"

strings2,s3;

Youcanassignonestringobjecttoanother:

s2=s1\n"

s2=s1;

s1:

s1<

s2:

s2<

Youcanassignac-stylestringtoastringobject.\n"

s2=\"

buzzard\"

s2="

buzzard"

s2:

Youcanconcatenatestrings:

s3=s1+s2

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

当前位置:首页 > 工作范文 > 制度规范

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

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