Question
C++ Can you please edit the main() function to get the proper results shown below Code: #include #include #include #include #include #include using namespace std;
C++ Can you please edit the main() function to get the proper results shown below
Code:
#include
#include
#include
#include
#include
#include
using namespace std;
//------
struct card
{
enum class suit { club, spade, diamond, heart };
enum { ace=1, jack=10, queen=11, king=12 };
using number = int;
number num_;
suit suit_;
};
bool operator ==(card const& a, card const& b)
{
return a.num_ == b.num_ && a.suit_ == b.suit_;
}
bool operator
{
return a.num_
}
istream& operator >>(istream& is, card& c)
{
// number followed by the suit (CSHD)...
is >> c.num_;
char ch;
if (is >> ch)
{
switch (ch)
{
case 'C': c.suit_ = card::suit::club; break;
case 'S': c.suit_ = card::suit::spade; break;
case 'H': c.suit_ = card::suit::heart; break;
case 'D': c.suit_ = card::suit::diamond; break;
default:
is.setstate(ios::failbit);
break;
}
}
else
is.setstate(ios::badbit);
return is;
}
ostream& operator
{
os
switch (c.suit_)
{
// card::suit allows us to access suit
// suit::club allows us to access club
// thus, card::suit::club lets us access club
case card::suit::club:
os
break;
case card::suit::spade:
os
break;
case card::suit::diamond:
os
break;
case card::suit::heart:
os
break;
}
return os;
}
//------
int main()
{
map
string i;
while(cin >> i)
{
auto[pos, isAdded] = freqHist.insert({i,1});
if (!isAdded)
++pos->second;
}
cout
for (auto const& elem : freqHist)
cout
}
Sample Program Input The program input will be a series of zero or more cards. (Read the input until EOF or an error.) For example, sample input might be placed in a file called input.dat, e.g. 1. 2. $ cat input.dat 10D3S4H9C10D8H2D12S10D6H2D4H $ 3. Sample Program Run The program output for the above input.dat file is: 1. 2. 4. 5. 6. $ g++-10.2.0 -Wall - Wextra Werror a3.cxx $ ./a.outStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started