03 2021 档案
程序清单10.7,10.8,10.9-课本298,299,301页
摘要:stock20.h #ifndef STOCK20_H_#define STOCK20_H_#include<string> class Stock{private: std::string company; int shares; double share_val; double total_va
阅读全文
程序清单10.4,10.5,10.6——课本291,292,293页
摘要:stock10.h #ifndef STOCK10_H_#define STOCK01_H_#include<string> class Stock{private: std::string company; long shares; double share_val; double total_v
阅读全文
第11章练习题——344页
摘要:11.8-4 // prototype friend Stonewt operator*(double mult, const Stonewt & s); // definition — let constructor do the work Stonewt operator*(double mul
阅读全文
程序清单11.6,11.7,11.18——课本335,337页
摘要:stonewt.h #ifndef STONETW_H#define STONETW_Hclass Stonewt{private: enum {Lbs_per_stn=14}; int stone; double pds_left; double pounds;public: Stonewt(do
阅读全文
程序清单11.7,11.8,11.9——课本316,317,318页,重载减,乘运算符
摘要:mytime2.h #ifndef MTTIME2_H#define MYTIME2_H class Time{private: int hours; int minutes;public: Time(); Time(int h,int m=0); void AddMin(int m); void
阅读全文
程序清单11.4,11.5,11.6——课本313,314页,添加加法运算符
摘要:mytime1.h #ifndef MTTIME0_H#define MYTIME0_H class Time{private: int hours; int minutes; public: Time(); Time(int h,int m=0); void AddMin(int m); void
阅读全文
程序清单11.1,11.2,11.3——课本311,312页,计算时间:一个运算符重载示例
摘要:mytime0.h #ifndef MTTIME0_H#define MYTIME0_H class Time{private: int hours; int minutes; public: Time(); Time(int h,int m=0); void AddMin(int m); void
阅读全文
第十章练习题——308页
摘要:10.10-1 #include<iostream>#include<string>using namespace std;class user{private://数据成员 string name; string account;//账号 double money;//存款 public://成员
阅读全文
第五章练习题——135页
摘要:5.8-6 #include<iostream>int main(){ using namespace std; int i=1; while(i<=64) { cout<<i<<"、"; i=i*2; } cout<<endl; system("pause"); return 0;} 5.9-1
阅读全文
第五章 循环和关系表达式
摘要:程序清单5.3 #include<iostream>int main(){ using namespace std; int x; cout<<"The expression x = 100 has the value "; cout<<(x=100)<<endl; cout<<"Now x = "
阅读全文
第四章练习题——102页
摘要:4.12-13 #include<iostream>#include<vector>#include<array>using namespace std;int main(){ cout<<"Entre a positive integer:"; unsigned int num; cin>>num
阅读全文
程序清单4.20,4.21,4.22,4.23,4.24——课本92,95,95,98,100页
摘要:如何使用不同形式的字符串 #include<iostream>#include<cstring>using namespace std;int main(){ char animal[20]="bear"; const char* bird="wren"; char* ps; cout<<anima
阅读全文
程序清单4.14,4.15,4.16,4.17,4.18,4.19——课本74,76,83,85,88,88页
摘要:取地址运算符&用法 #include<iostream>using namespace std;int main(){ int donuts=6; double cups=4.5; cout<<"donuts value = "<<donuts; cout<<" and donuts address
阅读全文
程序清单4.11,4.12,4.13——课本74,76,77页
摘要:在程序中使用结构 #include<iostream>using namespace std;struct inflatable{ char name[20]; float volume; double price;};int main(){ inflatable guest= { "Gloriou
阅读全文
程序清单4.8——课本69页
摘要:1 可以将string对象声明为简单变量,而不是数组 #include<iostream>#include<string>using namespace std;int main(){ char charr1[20]; char charr2[20]="jaguar"; string str1; s
阅读全文
程序清单4.4,4.5,4.6——课本66,67页
摘要:使用cin.getlint( ) #include<iostream>using namespace std;int main(){ const int ArSize=20; char name[ArSize]; char dessert[ArSize]; cout<<"Enter your nam
阅读全文
程序清单4.1——课本60页,马铃薯分析程序
摘要:#include<iostream>using namespace std;int main(){ int yams[3]; yams[0]=7; yams[1]=8; yams[2]=6; int yamcosts[3]={20,30,5}; cout<<"Total yams = "; cout
阅读全文
第三章练习题——58页
摘要:3.7-1 #include<iostream>const int change=12;using namespace std;int main(){ cout<<"Please entre your height:__\b\b";//单位英寸 int height; cin>>height; co
阅读全文
程序清单3-4 课本56页
摘要:#include<iostream>using namespace std;int main(){ int auks,bats,coots; auks=19.99+11.99; bats=(int)19.99+(int)11.99; coots=int(19.99)+int(11.99); cout
阅读全文
程序清单3.8 课本48页
摘要:#include<iostream>using namespace std;int main(){ cout.setf(ios_base::fixed,ios_base::floatfield); float tub=10.0/3.0; double mint=10.0/3.0; const flo
阅读全文
程序清单3.7 课本44页
摘要:#include<iostream>using namespace std;int main(){ cout<<"\aOperation\"HyperHype\" is now activated!\n"; cout<<"Enter your agent code:_______\b\b\b\b\b
阅读全文
程序清单3.4 课本40页
摘要:#include<iostream>using namespace std;int main(){ int chest=42; int waist=42; int inseam=42; cout<<"Monsieur cuts a striking figure!"<<endl; cout<<"ch
阅读全文
程序清单3.2 课本37页
摘要:#include<iostream>#include<climits>#define ZERO 0;using namespace std;int main(){ short sam=SHRT_MAX; unsigned short sue=sam; cout<<"Sam has "<<sam<<"
阅读全文
程序清单3.1 课本35页
摘要:#include<iostream>#include<climits>using namespace std;int main(){ int n_int=INT_MAX; short n_short=SHRT_MAX; long n_long=LONG_MAX; long long n_llong=
阅读全文
第二章练习题——30页
摘要:2.7-3 #include<iostream>using namespace std;void mice();void oneint();int main(){ mice(); mice(); oneint(); oneint(); system("pause");}void mice(){ co
阅读全文
浙公网安备 33010602011771号