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
Mrrafil [7]
1 year ago
3

(In C++) Write a function that returns the intersection of two vectors using the following header:

Engineering
1 answer:
Sati [7]1 year ago
8 0

The common strings are Dallas Boston:

#include <iostream>
#include <vector>

using namespace std;

template<typename T>
vector<T> intersect(const vector<T>& v1, const vector<T>& v2) {
   vector<T> vec;
   for(int i = 0; i < v1.size(); ++i) {
       for(int j = 0; j < v2.size(); ++j) {
           if(v1[i] == v2[j]) {
               vec.push_back(v2[j]);
               break;
           }
       }
   }
   return vec;
}

int main() {
   vector<string> v1;
   v1.push_back("Atlanta");
   v1.push_back("Dallas");
   v1.push_back("Chicago");
   v1.push_back("Boston");
   v1.push_back("Denver");    

   vector<string> v2;
   v2.push_back("Dallas");
   v2.push_back("Tampa");
   v2.push_back("Miami");
   v2.push_back("Boston");
   v2.push_back("Richmond");    

   vector<string> v3 = intersect(v1, v2);
   cout << "The common strings are ";
   for(int i = 0; i < v3.size(); ++i) {
       cout << v3[i] << " ";
   }
   cout << endl;
   return 0;
}

What is string?
A string is typically a sequence of characters in computer programming, either as a literal constant as some sort of variable. The latter can either be fixed or its elements and length can be altered (after creation). A string is commonly implemented as just an array data structure comprising bytes (or words) that contains a sequence of elements, typically characters, using some character encoding. A string is generally thought of as a type of data. A string can also represent various sequence(or list) data types and structures, such as more complex arrays. A variable declared as a string may enable memory storage to be statically allocated for a set maximum length or utilise dynamic allocation that allow it to retain a variable number of elements, appropriate programming language and specific data type used.

To learn more about string
brainly.com/question/25324400
#SPJ4

You might be interested in
A disc brake rotor is being machined. Technician A says that a feed rate of 0.0008 inch per revolution and 150 RPM is where the
erma4kov [3.2K]

Answer:

Technician B only

Explanation:

During rotor reconditioning, which is the process also known as machining and sanding, where sanding is the involves the application of between 120 and 150 grit sandpaper while using a non-excessive force that is applied non-directionally for up to 60 seconds on each side such that the surface roughness meets OE standards. The rotors are then cleaned by washing after they are serviced before they can then be installed.

3 0
3 years ago
Two kg of N2 at 450 K, 7 bar is contained in a rigid tank connected by a valve to another rigid tank holding 1 kg of O2 at 300 K
11111nata11111 [884]

Answer:WHo knows.Explanation:

7 0
3 years ago
A/an _____________ comes on if one of the dual hydraulic brake systems should fail or, in some vehicles, if the brake fluid is l
jolli1 [7]

Answer: Dash light

Explanation:

A dash light, usually labeled "BRAKE" will illuminated if a braking system fails, or if the brake fluid is low.

3 0
3 years ago
Identify five safety hazards that should be included in the design of the school
erik [133]

Answer:

1) function of fire doors and making sure theyre properly wired to fire alarms

2) proper water piping and purifaction for water fountains and sinks.

3)  falty sprinkler systems/rsuty sprikler systems that wont work

4) weather durable roofing and walls for storms and snow depending on were your located .

5) rsuted pipes in showers or fountains that could give you tetnus or other disaeases

Explanation:

HOPE THIS HELPS good luck!!

7 0
3 years ago
Two transmission belts pass over a double-sheaved pulley that is attached to an axle supported by bearings at A and D. The radiu
Fynjy0 [20]

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the step by step explanation to the question above.

6 0
4 years ago
Other questions:
  • The animation shows the circuit inside a speaker. The speaker cone vibrates as the current changes direction. This creates sound
    8·1 answer
  • Write the definition of a function printLarger, which has two int parameters and returns nothing. The function prints the larger
    14·1 answer
  • Consider an experiment in which the number of pumps in use at each of two seven-pump gas stations was determined. Call the two g
    10·1 answer
  • Typical metals show elastic-plastic behaviour in tension and shear but not in compression. a)True b)- False
    9·1 answer
  • A turbine operates at steady state, and experiences a heat loss. 1.1 kg/s of water flows through the system. The inlet is mainta
    6·1 answer
  • suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign
    11·1 answer
  • A force 25 N makes an angle of 30,45 and 75 degree with x,y and z axis. What should be the corresponding force vector?
    8·1 answer
  • The development of various technologies led to many historic events. Use information from the Internet to describe one major his
    5·1 answer
  • What is the best way to cut a taper
    5·2 answers
  • What is the correct procedure for mounting the m240 on the m122a1 tripod after the pintle is attached to the receiver?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!