#include<iostream>
#include"Sales_data.h"
using namespace std;
int main()
{
Sales_item total;
cout << "Please input the bookNo units_sold price:" << endl;
if (cin >> total)
{
int cnt = 1;
Sales_item trans;
while (cin >> trans)
{
if (trans.isbn() == total.isbn())
{
total += trans;
++cnt;
}
else
{
cout << total.isbn() << " occurs "
<< cnt << " times" << endl;
total = trans;
cnt = 1;
}
}
cout << total.isbn() << " occurs "
<< cnt << " times" << endl;
}
else
cerr << "enter error!";
return 0;
}
C++Primer第五版:练习1.23 1.24
最新推荐文章于 2022-03-08 22:05:53 发布