C++Primer中文版(第四版)题解整理(10)
时间:2025-04-20
时间:2025-04-20
C++Primer题解
system("CLS");
cout<<"Entertransactions:"<<endl;
if(cin>>total)
{
while(cin>>trans)
if(total.same_isbn(trans))//ISBN相同
total=total+trans;
}
else
{//ISBN不同
cout<<"DifferentISBN."<<endl;
return-1;
}
//输出交易之和
cout<<"Thetotalinformation:"<<endl
<<"ISBN,numberofcopiessold,"
<<"totalrevenue,andaveragepriceare:"
<<endl<<total;
else
{
cout<<"Nodata?!"<<endl;
return-1;
}
return0;
}
习题1.24
编写程序,读入几笔不同的交易。对于每笔新读入的交易,要确定它的ISBN是否和以前的交易的ISBN一样,并且记下每一个ISBN的交易的总数。通过给定多笔不同的交易来测试程序。这些交易必须代表多个不同的ISBN,但是每个ISBN的记录应分在同一组。