手机版

C++Primer中文版(第四版)题解整理(9)

时间:2025-07-09   来源:未知    
字号:

C++Primer题解

Sales_itembook;

system("CLS");

cout<<"Entertransactions:"<<endl;

while(cin>>book){

//输出ISBN,售出书的本数,总收入,平均价格

cout<<"ISBN,numberofcopiessold,"<<"totalrevenue,andaveragepriceare:"<<endl;

cout<<book<<endl;

}

return0;

}

习题1.22

编写程序,读入两个具有相同ISBN的Sales_item对象并产生它们的和。#include<iostream>

#include"Sales_item.h"

#include"windows.h"

usingnamespacestd;

intmain()

{

Sales_itemtrans1,trans2;

//读入交易

system("CLS");

cout<<"Entertwotransactions:"<<endl;

cin>>trans1>>trans2;

if(trans1.same_isbn(trans2))

cout<<"Thetotalinformation:"<<endl

<<"ISBN,numberofcopiessold,"

<<"totalrevenue,andaveragepriceare:"

<<endl<<trans1+trans2;

else

cout<<"ThetwotransactionshavedifferentISBN."<<endl;

return0;

}

习题1.23

编写程序,读入几个具有相同ISBN的交易,输出所有读入交易的和。#include<iostream>

#include"Sales_item.h"

C++Primer中文版(第四版)题解整理(9).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)