Answered step by step
Verified Expert Solution
Question
1 Approved Answer
DO NOT DELETE ANY SECTIONS OF THIS PROGRAM. SIMPLY ADD YOUR CODE IN THE APPROPRIATE SECTIONS REWRITE WHOLE THING IN C + + * /
DO NOT DELETE ANY SECTIONS OF THIS PROGRAM. SIMPLY ADD YOUR CODE IN THE
APPROPRIATE SECTIONS REWRITE WHOLE THING IN C
#include
#include
#include
#include
using namespace std;
void displayMenu;
int getChoice;
void STLAlgorithms;
void functionObjectsLambda;
void doubleNumbersint #
bool outOfRangeint num;
class Sum
public:
int operator int num int num return num num;
;
int main
const int SELECTION ;
int choice;
do
displayMenu;
choice getChoice;
ifchoice SELECTION
switchchoice
case : STLAlgorithms; break;
case : functionObjectsLambda; break;
whilechoice SELECTION;
current date and time on the current system
timet dateTime timeNULL;
cout
Thank you for using this tutorial. I hope you enjoyed
"learning.
"Date : char ctime&dateTime endl
"Author: Prof. Mathieu KOKOLY Kourouma, PhD
All Rights Reserved
;
return ;
void displayMenu
cout endl;
cout
;
cout setwCMPS B Data Structures Spring
;
cout setw "Project
"Due: Friday, March @ : PM in Moodle
;
cout "The topics to be discussed are:
More on STL Algortihms
Function Objects and Lambda Expressions
Quit the tutorial program
;
cout
;
int getChoice
int choice;
cout
Enter your selection: ;
cin choice;
whilechoice choice
cout
;
cout "Invalid input. Valid choices are to
;
cout
;
cout "Please enter again your selection: ;
cin choice;
return choice;
void STLAlgorithms
cout
;
cout
More on STL Algortihms Tutorial
"You have already learned and programmed some STL algorithms,
"such as the sort, binarysearch, setunion, setintersection,
"setdifference, setsymmetric, and includes functions.
In this tutorial, you will learn about ispermutation, foreach,
"and countif functions.
;
cout Using the ispermutation function
;
cout "Given the following vectors:
;
cout "vector winningNumbers
"vector playerOneNumbers and
"vector playerTwoNumbers
;
cout "The program determines which player's numbers are a permutation
"the winning numbers, as in a lottery.
;
vector winningNumbers ;
vector playerOneNumbers ;
vector playerTwoNumbers ;
ifispermutationwinningNumbersbegin winningNumbers.end
playerOneNumbers.begin
cout "Player won the lottery!
;
else
cout "Sorry player You did not win the lottery.
;
ifispermutationwinningNumbersbegin winningNumbers.end
playerTwoNumbers.begin
cout "Player won the lottery!
;
else
cout "Sorry player You did not win the lottery.
;
cout
Using the foreach function
;
cout "Given the following vector:
;
cout "vector numbers
;
cout "The program doubles every element in the vector numbers.
;
vector numbers ;
foreachnumbersbegin numbers.end doubleNumbers;
cout "Now, the numbers vector elements are:
;
cout "vector numbers ;
forint element ; element numbers.size; element
ifelement numberssize
cout numberselement;
else cout numberselement;
cout
;
cout
Using the countif function
;
cout "Given the following vector:
;
cout "vector integers
;
cout "The program counts the
Step 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