Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It's raining frogs and fleas. Write a function that tells you if the number of frogs in a sentence is the same as the number

image text in transcribed

It's raining frogs and fleas. Write a function that tells you if the number of frogs in a sentence is the same as the number of fleas. Complete the following file: main.cpp 1 #include 2 #include 3 using namespace std; 4 5 bool fleasNFrogs (const string& s) 6 { 7 bool result{false}; 8 int frogsCount:0, fleasCount=0; 9 for(std::size_t foundl=s.find("frogs"), found2=s.find("fleas"); found1!=std::string:: npos II found2!=std::string:: npos;) 10 { 11 if(found1!=std::string:: npos) 12 { 13 frogsCount++; 14 foundl=s.find("frogs", found1+1); 15 } 16 if(found2!-std::string:: npos) 17 { 18 fleasCount++; 19 found2-s.find("fleas", found2+1); 20 } 21 } 22 if(frogsCount==fleasCount) 23 result=true; 24 25 26 27 return result; 28 } Submit Calling with Arguments Name Arguments Actual Expected pass fleasNFrogs "frogflea" true true fail Eleas Frogs 'frogfrog" true false pass fleasNFrogs 'lfroglcadoflea" true true fail fleasNFrogs 'frogxxfleaxxxflea true false pass fleasNFrogs 'frogxfleaxfleaxfrog" true true fail fleas Frogs 'frogxfleaxfleaxca. true false fail Fleas Frogs "fleafleafrog true false pass fleasNFrogs 'fleaogfrog" true true fail fleas Frogs flea" true false fail Eleas Frogs 'frog true false pass fleasNFrogs "ca" true true pass fleasNFrogs "e" true true pass fleasNFrogs" true true

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions