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
Leno4ka [110]
3 years ago
6

) write a program that creates a vector of string called "vec". vector "vec" grows and shrinks as the user processes the transac

tions from a data file called "transaction.txt". the transaction file can only include three types of commands: add, remove, and print. with "add" command, you get two more information, the information you need to put into the vector and the position the information should be inserted. with "remove", you get one more information that indicates which element (index) should be deleted. print command means the content of the vector should be printed on the screen.
Computers and Technology
1 answer:
BigorU [14]3 years ago
8 0

PROGRAM:

#include <iostream>

#include <vector>

#include <fstream>

#include <sstream>

#include <string>

using namespace std;

vector<string> vec(20);

vector<string>::iterator it;

int main() {

  ifstream infile("Transaction.txt");

  string line;

  while(getline(infile,line))

  {

      istringstream iss(line);

      string command;

      iss>>command;

      if(command == "Add")

      {

          string word;

          int position;

          iss>>word>>position;

          vec.insert(vec.begin() + position, word);

      }

      else if(command == "Remove")

      {

          int position;

          iss>>position;

          vec.erase(vec.begin() + position);

      }

      else if(command == "Print")

      {

          for (vector<string>::const_iterator i = vec.begin(); i != vec.end(); ++i)

          {

              if(*i != "")

              {

                      cout << *i << "\n";

              }

          }

      }

  }

  return 0;

}

You might be interested in
A security system uses sensors at every door and window which will set off an alarm if any one of them is opened. There is also
AnnyKZ [126]
You have a raspberry pi connected to all the sensors and a code running to  trigger if the sensors are triggered. Each sensor and keypad would run to a different input on the pi. They should al be able to be powered with a single cell lipo. Is that what you are asking?
5 0
3 years ago
I have a question about a hotel tv:
UNO [17]

1 Open the back cover of the Nintendo Switch Dock.

2 Connect the USB plug from the Nintendo Switch AC adapter (model No. ...

3 Connect one end of the HDMI cable into the bottom terminal of the dock labeled "HDMI OUT," then connect the other end into an HDMI port on your television or monitor.

                                                                                                   your welcome

3 0
3 years ago
You are a network engineer tasked with performing a site survey for a multiple-channel architecture (MCA) system in a three-stor
blagie [28]

Answer:

20/20 vision, and quick internal math if you are talking about human characteristics. If you are talking about the sight survey itself and considering other aspects; You would want to make sure the site has an easily accessible area for the client, doing this by considering the following: easy access, building height (cell phone tower correspondents), multi-channel sight points, and wiring less visible than the access point.

Explanation:

5 0
3 years ago
Lorann sends messages to Aiden that always go into Aiden's Junk E-mail folder. Which process would best correct this problem so
BaLLatris [955]
Go to settings and find out.
7 0
3 years ago
If you don’t have a paper copy of the FAFSA form, how else can you fill it out?
Ronch [10]
Go on your school computer, and find a copy of the form. Then print it from the school printer.
3 0
3 years ago
Read 2 more answers
Other questions:
  • Type the correct answer in the box. Spell the word correctly.
    14·2 answers
  • Kaiden would like to find the list of physical disk drives that are connected to a Linux system. Which directory contains a subd
    14·1 answer
  • Can I recover my data from HDD if I just started formatting but did not finish it? (I ceased it!)
    7·1 answer
  • "This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some out
    15·1 answer
  • The first step in the five-step process for problem solving is to ____. take action complete the task understand the task or nee
    10·2 answers
  • Show the CREATE TABLE statements for HAPPY INSURANCE database for the table CLIENT (assume that non-primary key columns can be o
    7·1 answer
  • List three ways security could be improved for taking the prepared deposit monies to the bank?​
    11·1 answer
  • Explain default dictionary in microsoft word​
    9·1 answer
  • How do you invite someone to a conversation on brainly
    14·1 answer
  • Who is this wrong answers only
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!