Complete the function CheckAll() that takes one string parameterand one character parameter. The function returns true if all thecharacters in the string are not equal to the character parameter.Otherwise, the function returns false.
Ex: If the input is ddpz p, then the output is:
False, at least one character is equal to p.
Here is the template of the problem, please use it:
#include <iostream>using namespace std;
bool CheckAll(string inputString, char x) {
#include <iostream>#include<vector>using namespace std;
//Code for PickIndices functionvoid pickIndices(string a, char b, vector<int>&results){int i=0;for(i=0; i< a.size() ; i++){if(a==b){results.push_back(i);}}}
}
int main() { string inputString; char x; bool result;
cin >> inputString; cin >> x;
result = CheckAll(inputString, x);
if (result) { cout << "True, all thecharacters are not equal to " << x << "." <<endl; } else { cout << "False, atleast one character is equal to " << x << "." <<endl; }
return 0;}
Complete the function CheckAll() that takes one string parameter and one character parameter. The function returns true
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am