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
I just logged onto brainly and all my questions were deleted and i lost 2 brainliest. What has brainly done to my account I also
krok68 [10]
I’d say message Brainly directly through email!! it would be easier for them to help solve the issue since all we really can do is assume what happened, I hope you’re able to figure it out =)
5 0
3 years ago
Read 2 more answers
What is the meaning for science?
ELEN [110]
Science is the special kind of knowledge.Science is the special kind of knowledge related to nature and natural phenomena.
5 0
3 years ago
You can not give an exact size for a height for column width true or false
GalinKa [24]

Answer:

~false~

Explanation:

5 0
3 years ago
What type of memory or storage device is prone to losing data if the power goes out?
Veseljchak [2.6K]
The answer is (c.) a DDR SDRAM module.

DDR SDRAM stands for Double data rate synchronous dynamic random-access memory. It is a form of temporary data storage in a computer. So when it comes to power down, the data stored in this RAM is most likely to lose.
7 0
3 years ago
Taylor is getting ready to send an e-mail. In three to five sentences, give Taylor some advice for sending an effective email.
KengaRu [80]

Answer:

  • Include subject lines since they are important
  • use bullet points
  • keep it short
  • avoid too many exclamation marks
  • watch your tone
3 0
3 years ago
Other questions:
  • Due to the shift from host-based networks to microcomputer based networks, more than _____ percent of most organizations' total
    8·1 answer
  • An IT company revises its process parameters in response to complaints from vendors that products were not ready on time. This w
    15·1 answer
  • What are the modes of operation of WLANs?
    5·1 answer
  • Explain the importance of determinism in an industrial LAN
    8·1 answer
  • Q.2 (A)
    5·1 answer
  • Dash transfers several bits of data together at one time<br>​
    6·1 answer
  • Examples of applying successful visual design principles to bring a web page together are _________________. (Choose all that ap
    9·1 answer
  • What ways does e-governance empower citizens
    15·1 answer
  • Sidney needs to create a decimal number variable that will be added to another number. What kind of variable is required?binaryB
    15·1 answer
  • Which of the following tiny computer apps is designed to be useful but could cause more harm than good?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!