c++primerplus中文版第六版源代码.docVIP

  • 41
  • 0
  • 约1.7万字
  • 约 42页
  • 2019-09-19 发布于安徽
  • 举报
. . C++ primer plus 中文版 第六版 源代码 第二章到第四章,后续继续更新……… 第二章 1:#includeiostream void main() { using namespace std; int carrots; carrots=25; coutI have ; coutcarrots; coutcarrots.; coutendl; carrots=carrots-1; coutCrunch,crunch.Now I have carrots carrotsendl; } 2:#includeiostream int stonetolb(int); int main() { using namespace std; int stone; coutEnter the weight in stone: ; cinstone; int pounds=stonetolb(stone); coutstone stone= ; coutpounds pounds.endl; return 0; } int stonetolb(int sts) { return 14*sts; } 3:#includeiostream void main() { using namespace std; int carrots; carrots=25; coutHow many carrots do you have?endl; cincarrots; coutHere are two more.; carrots=carrots+2; coutNow you have carrots carrots.endl; //下两行专门测试cin.get() cin.get(); cin.get(); } 4:#includeiostream using namespace std; void main() { coutCome up and C++ me some time.; coutendl; coutYou wont regret it!endl; } 5#includeiostream void simon(int); int main() { using namespace std; simon(3); coutPick an integer: ; int count; cincount; simon(count); coutDone !endl; return 0; } void simon(int n) { using namespace std; coutSimon says touch your toes n times.endl; } 6:#includeiostream #includecmath void main() { using namespace std; double area; coutEnter the floor arae,in square feet,of your home: ; cinarea; double side; side=sqrt(area); coutThats the equivalent of a square side feet to the side.endl; coutHow fascinating!endl; } 第三章 1:#includeiostream #includeclimits using namespace std; int main() { int n_int=INT_MAX; short n_short=SHRT_MAX; long n_long=LONG_MAX; coutint is sizeof(int) bytes.endl; coutshort issizeof n_short bytes.endl; coutlong issizeof n_long bytes.endlendl; coutMaximum values :endl; coutint :n_intendl; coutshort :n_shortendl; coutlong :n_longendl; coutMinimum int value = INT_MINendl; coutBits per byts = CHAR_BITendl; return 0; } 2:#includeiostream #

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档