c++ primer plus 中文版 第六版源代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
C++ primer plus 中文版第六版源代码
第二章到第四章,后续继续更新………
第二章
1:#include
void main()
{
using namespace std;
int carrots;
carrots=25;
cout<<"I have ";
cout< cout<<"carrots."; cout< carrots=carrots-1; cout<<"Crunch,crunch.Now I have "< } 2:#include int stonetolb(int); int main() { using namespace std; int stone; cout<<"Enter the weight in stone: "; cin>>stone; int pounds=stonetolb(stone); cout< return 0; } int stonetolb(int sts) { return 14*sts; } 3:#include void main() { using namespace std; int carrots; carrots=25; cout<<"How many carrots do you have?"< cin>>carrots; cout<<"Here are two more."; carrots=carrots+2; cout<<"Now you have "< cin.get(); cin.get(); } 4:#include using namespace std; void main() { cout<<"Come up and C++ me some time."; cout< cout<<"You won't regret it!"< } 5#include void simon(int); int main() { using namespace std; simon(3); cout<<"Pick an integer: "; int count; cin>>count; simon(count); cout<<"Done !"< return 0; } void simon(int n) { using namespace std; cout<<"Simon says touch your toes "< } 6:#include #include void main() { using namespace std; double area; cout<<"Enter the floor arae,in square feet,of your home: "; cin>>area; double side; side=sqrt(area); cout<<"That's the equivalent of a square "< cout<<"How fascinating!"< } 第三章 1:#include #include using namespace std; int main() { int n_int=INT_MAX; short n_short=SHRT_MAX; long n_long=LONG_MAX; cout<<"int is "< cout<<"short is"< cout<<"long is"< cout<<"Maximum values :"< cout<<"int :"< cout<<"short :"< cout<<"long :"< cout<<"Minimum int value = "< cout<<"Bits per byts = "< return 0; }