String Splitter
Write a function vector<string> split (string str) that takes a string as parameter and returns a vector of the distinct words in the string. A distinct word is any run of characters delimited by the beginning of the string, the end of the string, or whitespace. A consecutive run of whitespace characters is to be treated the same as a single whitespace character. Test your
Every good boy does fine,
results in the output
Every
good
boy
does
fine.
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out With Visual Basic (8th Edition)
- C++ Vectors Help: write a program using parallel vectors and a function which fills each of them with 500 random numbers between 1 and 100. The program should then pass both vectors to a function which will return an integer indicating a count of how many times both vectors had even numbers in the same location. So if vector01[0] contained 4 and vector02[0] contained 12, you would add one to count.If vector01[1] contained 3 and vector02[1] contained 4, you would not add one to count. main would display something like : The Vectors contain 128 cells where both values are even. Above was the question: I already have the code written: #include<iostream> #include<vector> #include<cstdlib> #include<ctime> using namespace std; int main() { int even = 0; srand(time(0)); vector <int> vector01; vector <int> vector02; for (int i = 0; i < 500; i++) { vector01.push_back(rand() % 100 + 1); vector02.push_back(rand() % 100 + 1); if (vector01[i] % 2 == 0…arrow_forwardPlease complete the following functions: 1. int loadDictionary(istream& dictfile, vector<string>& dict) 2. int permute(string word, vector<string>& dict, vector<string>& results) 3. void display(vector<string>& results)arrow_forwardWrite a function namedisInt that hasone parm, a stringand returnsanint. The function should return true (in the C sense) if the string contains an int (all characters in the string are digits) and return false (in the C sense) otherwise. USE POINTER NOTATION INSTEAD OF ARRAY NOTATION. NO BRACKETS.arrow_forward
- In C++: Define a function that reads input 5 integers from the user, stores them in a vector, and then returns the vector from the function.arrow_forward- Write a function that takes a vector and returns the maximum element. - Same as above, but without using the "max" function.arrow_forwardC++arrow_forward
- In C++, define an integer vector and ask the user to give you values for the vector. Because you used a vector, so you don't need to know the size. user should be able to enter a number until he wants(you can use while loop for termination. for example if the user enters any negative number, but until he enters a positive number, your program should read and push it inside of the vector). the calculate the average of all numbers he entered.arrow_forwardThis one. in c++arrow_forward1. Write a function that returns a vector. The function will accept names (full names: Given, Middle, & Family name for each) for the vector string to be returned as many as the user will enter. The enter key will just be the data required to end the input process. 2. Write a function that returns a vector with given names. The function will extract the given name from all the elements of the vector specified as parameter. The extracted given names will be assigned to another vector that is to be returned. 3. Write a function with vector as it's parameter. The function will display all elements of the vector specified. 4. Write a program for using all the functions created from number 1 to 3 above.arrow_forward
- Define the function: int countVowel(char word[]); The function returns the number of vowels the word.arrow_forwardIn C++ please: Read integers from input and store each integer into a vector until 0 is read. Do not store 0 into the vector. Then, output all values in the vector (including the last value) each multiplied by the last value in the vector. Output each value on a new line. Ex: If the input is -63 79 -48 7 0, the output is: -441 553 -336 49 #include <iostream>#include <vector>using namespace std; int main() { //place code herereturn 0;}arrow_forwardComplete the check_character() function which has 2 parameters: A string, and a specified index. The function checks the character at the specified index of the string parameter, and returns a string based on the type of character at that location indicating if the character is a letter, digit, whitespace, or unknown character. Ex: The function calls below with the given arguments will return the following strings: check_character('happy birthday', 2) returns "Character 'p' is a letter"check_character('happy birthday', 5) returns "Character ' ' is a white space"check_character('happy birthday 2 you', 15) returns "Character '2' is a digit"check_character('happy birthday!', 14) returns "Character '!' is unknown" use python please def check_character(word, index): # Type your code here. if __name__ == '__main__': print(check_character('happy birthday', 2)) print(check_character('happy birthday', 5)) print(check_character('happy birthday 2 you', 15))…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr