# Transforming a sequence in vector : Vector Utility « Data Structure « C++

Home
C++
 1 Bitset 2 Class 3 Console 4 Data Structure 5 Data Type 6 Deque 7 Development 8 File 9 Function 10 Generic 11 Language 12 List 13 Map Multimap 14 Overload 15 Pointer 16 Qt 17 Queue Stack 18 Set Multiset 19 STL Algorithms Binary search 20 STL Algorithms Heap 21 STL Algorithms Helper 22 STL Algorithms Iterator 23 STL Algorithms Merge 24 STL Algorithms Min Max 25 STL Algorithms Modifying sequence operations 26 STL Algorithms Non modifying sequence operations 27 STL Algorithms Sorting 28 STL Basics 29 String 30 Valarray 31 Vector
 C++ » Data Structure » Vector Utility Screenshots
Transforming a sequence in vector
 ``` #include  #include  #include  using namespace std; double midpoint(double a, double b) {   return ((a-b) / 2) + b; } int main() {   vector vectorObject1(5), vectorObject2(5), vectorObject3(5);   int i;   vectorObject1[0] = 110.0;   vectorObject1[1] = 918.6;   vectorObject1[2] = 112.23;   vectorObject1[3] = 818.8;   vectorObject1[4] = -212.01;   vectorObject2[0] = 21.0;   vectorObject2[1] = 31.3;   vectorObject2[2] = 41.19;   vectorObject2[3] = 155.0;   vectorObject2[4] = -2.0;   cout << "Values in vectorObject1: ";   for(i = 0; i
Related examples in the same category
 1 Demonstrate inner_product() in vector 2 Demonstrate partial_sum() in vector 3 set_union, set_difference, set_symmetric_difference, set_intersection 4 Use a unary function object to determine even/odd. 5 Demonstrate count_if and not1 in vector 6 Another way to sort a sequence into descending order. 7 Use a function adaptor in vector 8 Demonstrate insert_iterator in a vector 9 Insert one vector into another using an insert iterator 10 Demonstrate back_insert_iterator in vector 11 Demonstrate front_insert_iterator in vector 12 Find minimum and maximum inside a vector 13 Use for_each() in vector 14 Use the logical_not unary function object in vector 15 Sorting a vector into descending order in vector 16 Using copy() in Vector 17 Using swap_ranges() in Vector 18 Exchange elements from two different types of containers. 19 Demonstrate find() and find_if() in vector 20 Demonstrate search() in vector 21 Demonstrate mismatch() in vector 22 Demonstrating sort() in vector 23 Demonstrating partial_sort() in vector 24 Demonstrate binary_search() in vector 25 Demonstrate lower_bound() in vector 26 Demonstrating remove() and replace() in vector 27 Demonstrating unique() in vector 28 Generating a sequence in vector 29 Rotate a sequence in vector 30 Right-rotate a sequence in vector 31 Demonstrate random_shuffle() in vector 32 Merge two sequences 33 A vector may allocate more memory than it currently needs.