Skip to content

Commit

Permalink
Update ex1_23.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Jun 18, 2015
1 parent 8ec06df commit c2ef230
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions ch01/ex1_23.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@

int main()
{
Sales_item currItem, valItem;
if (std::cin >> currItem)
{
int cnt = 1;
while (std::cin >> valItem)
Sales_item currItem, valItem;
if (std::cin >> currItem)
{
if (valItem.isbn() == currItem.isbn())
++cnt;
else
{
std::cout << currItem << " occurs "
<< cnt << " times " << std::endl;
currItem = valItem;
cnt = 1;
}
int cnt = 1;
while (std::cin >> valItem)
{
if (valItem.isbn() == currItem.isbn())
{
++cnt;
}
else
{
std::cout << currItem << " occurs " << cnt << " times " << std::endl;
currItem = valItem;
cnt = 1;
}
}
std::cout << currItem << " occurs "<< cnt << " times " << std::endl;
}

std::cout << currItem << " occurs "
<< cnt << " times " << std::endl;
}
return 0;
return 0;
}

0 comments on commit c2ef230

Please sign in to comment.