Question: 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

 It's raining frogs and fleas. Write a function that tells you

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!