1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Charra [1.4K]
3 years ago
6

Given the following header: vector split(string target, string delimiter); implement the function split so that it returns a vec

tor of the strings in target that are separated by the string delimiter. For example: split("10,20,30", ",") should return a vector with the strings "10", "20", and "30". Similarly, split("do re mi fa so la ti do", " ") should return a vector with the strings "do", "re","mi", "fa", "so", "la", "ti", and "do". Write a program that inputs two strings and calls your function to split the first target string by the second delimiter string and prints the resulting vector all on line line with elements separated by commas. A successful program should be as below with variable inputs:
Computers and Technology
1 answer:
suter [353]3 years ago
4 0

Answer:

see explaination

Explanation:

#include <iostream>

#include <string>

#include <vector>

using namespace std;

vector<string> split(string, string);

int main()

{

vector<string> splitedStr;

string data;

string delimiter;

cout << "Enter string to split:" << endl;

getline(cin,data);

cout << "Enter delimiter string:" << endl;

getline(cin,delimiter);

splitedStr = split(data,delimiter);

cout << "\n";

cout << "The substrings are: ";

for(int i = 0; i < splitedStr.size(); i++)

cout << "\"" << splitedStr[i] << "\"" << ",";

cout << endl << endl;

cin >> data;

return 0;

}

vector<string> split(string target, string delimiter)

{

unsigned first = 0;

unsigned last;

vector<string> subStr;

while((last = target.find(delimiter, first)) != string::npos)

{

subStr.push_back(target.substr(first, last-first));

first = last + delimiter.length();

}

subStr.push_back(target.substr(first));

return subStr;

}

You might be interested in
18) What is masking in Flash?
sammy [17]

Answer:

Ok thanks, I guess?

..............

6 0
3 years ago
Describe a situation when you would use a conditional statement in a program. Describe the action that would occur when the cond
kramer

Answer:  Conditional statements are just true false statements

Explanation:

Let's say there's a kpop band burglarizing my house and I have a super AI that detects if a kpop band is my house through cameras. What it would do is change a variable "kpopBandInHouse = False" to True. I would then have an if statement next with a custom function:

if kpopBandInHouse == True:

   nukeHouse()

So if the conditional statement is true, it nukes my house. It is false, it does not nuke my house.

7 0
3 years ago
Charles Lyell believed that:
yuradex [85]
D: slow processes of erosion and deposition shaped the earth
8 0
3 years ago
It’s illegal to hack into a system without authorization, but is it ethical for a gray-hat to hack into a system if the intent i
oksian1 [2.3K]

Answer:

Some hackers are smart about there hacking .. others have a a plot but didnt test there theory

Explanation:

8 0
3 years ago
Fitbit is an example of....
strojnjashka [21]

Answer:

a monitor of ur heartbeat sleep breathing

Explanation:

3 0
4 years ago
Read 2 more answers
Other questions:
  • A methods and measurements analyst for Digital Devices needs to develop a time standard for the task of assembling a computer mo
    15·1 answer
  • Write a C++ program that will ask the user for the name of a data file.
    11·1 answer
  • Which is an example of line-of-sight Internet service?<br> Cable<br> DSL<br> Fiber<br> WiMax
    7·1 answer
  • The site is not allowing me to purchase the subscription. Please help?
    12·1 answer
  • Each professional association has
    7·1 answer
  • Which term describes an approach to security similar to defense in depth in that it supports multiple layers, but uses a differe
    14·1 answer
  • Complete the output for the following program?
    10·1 answer
  • Are you familiar with measuring using a ruler? When have you ever used a ruler to measure, and who taught you how to use the rul
    13·1 answer
  • Need help coding this it uses input and I need to use the words good and morning
    10·1 answer
  • What ways does e-governance empower citizens
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!