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
6 external parts of computer
vivado [14]
<span>External computer parts are those that connect to the case, often to provide ways to input or output data.

Here are a 6 examples of external parts:
</span>Monitor
Keyboard
Mouse
Speakers
Printer
External Hard Drives

I hope this has helped you.
6 0
3 years ago
Read 2 more answers
How to add running head and page number in word?
yaroslaw [1]
If you go into word and click the insert table you will see a section that says header, footer and page number. That is where you add a head and page number. 
4 0
4 years ago
Identify a logical operation (along
tankabanditka [31]

Answer: Provided in the explanation section

Explanation:

The Question says;

Identify a logical operation (along

with a corresponding mask) that, when

applied to an input string of 8 bits,

produces an output string of all 0s if and

only if the input string is 10000001.​

The Answer (Explanation):

XOR, exclusive OR only gives 1 when both the bits are different.

So, if we want to have all 0s, and the for input only 10000001, then we have only one operation which satisfies this condition - XOR 10000001. AND

with 00000000 would also give 0,

but it would give 0 with all the inputs, not just 10000001.

Cheers i hope this helped !!

3 0
4 years ago
Describe the difference between information poor and information rich society?​
Nadya [2.5K]

Answer:

The “Information poor” are consumers who use traditional mass media information such as television, DVDs, radios and magazines. ... On the opposite “information rich” stands for a new elite within the information society.

7 0
3 years ago
Read 2 more answers
What does an Office employee use a computer for??
Neko [114]

Answer:

Work?

Explanation:

6 0
3 years ago
Other questions:
  • Which of the following is not true about managing your privacy settings? (select all that apply)
    9·2 answers
  • Timing circuits are a crucial component of VLSI chips. Here’s a simple model of such a timing circuit. Consider a complete balan
    10·1 answer
  • What is a organisation in office technology
    7·1 answer
  • It is advised to always have discretion with leaders. Explain in general terms what information security policies can and cannot
    12·1 answer
  • Angelina has added page numbers to her report, but all of the pages are labeled "Page 1" at the bottom. What caused
    8·2 answers
  • The sales of last 6 months are stored in a list,
    12·1 answer
  • Lập trình web truy vấn csdl và hienr thị ra màn hình danh sách các bản ghi
    15·1 answer
  • _________________ component defines the correct granularity for access controls and oversees the relationships between identitie
    13·1 answer
  • Green computing can be achieved by: a. using video conferencing, electronic meeting systems, and groupware. b. replacing meeting
    11·1 answer
  • If you want to change your system settings, what should you use
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!