Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed

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 freqHist;

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.out

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

Be familiar with the integrative servicescape model.

Answered: 1 week ago

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago