In the C++ program "Vectors.cpp," I've developed a set of experiments to demonstrate various vector operations. The experiement02 function, which is currently called in the main function, focuses on working with three vectors: v, v1, and v2. The goal is to find common elements between v and v1 and store them in v2. This is achieved by iterating through the elements of v, checking their presence in v1, and appending them to v2 if they are not already present. The results are printed using the printIntVector function.
I've included commented-out code for experiement01, which involves modifying and searching elements in a vector (v1). The addingVector function increments each element in v1 by a specified value (addingItems), and the returnIndice function finds the index of the first occurrence of a specified key in the vector. The modified vector and the result of the search operation are then printed.
The program is structured to be easily understood, and the commented-out code provides an alternative experiment that demonstrates additional vector manipulations. The printIntVector function facilitates the clear display of vector contents, enhancing the program's readability.