I am trying to merge two vectors, alternating elements from both vectors. And if one vector is longer than the other, alternate as long as possible then append the remaining elements from the longer vector. This is what I have so far:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main ()
{
vector<int> vector_a, vector_b, vector_c;
int i;
for(i=0; i+=2)
vector_a.push_back('A'+i);
for(i=0; i+=2)
vector_b.push_back('B'+i);
cout << "Original contents of vector a: ";
for (i=0; i vector_a.size(); i++)
cout <<vector_a[ i ];
cout << endl;
cout << "Original contents of vector b: ";
for(i=0; i vector_b.size();i++)
cout << vector_b[ i ];
cout << endl;
merge (vector_a.begin(), vector_a.end(), vector_b.begin(), vector_b.end(), vector_c.begin());
cout << "Result of merge:\n";
for(i=0; i vector_c.size(); i++)
cout << vector_c[ i ];
return 0;
}
feedback:
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(12) : error C2143: syntax error : missing ';' before ')'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(14) : error C2143: syntax error : missing ';' before ')'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(18) : error C2146: syntax error : missing ';' before identifier 'vector_a'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(18) : error C2146: syntax error : missing ')' before identifier 'i'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(18) : error C2059: syntax error : ';'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(18) : error C2059: syntax error : ')'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(19) : error C2146: syntax error : missing ';' before identifier 'cout'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(23) : error C2146: syntax error : missing ';' before identifier 'vector_b'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(23) : error C2146: syntax error : missing ')' before identifier 'i'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(23) : error C2059: syntax error : ';'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(23) : error C2059: syntax error : ')'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(24) : error C2146: syntax error : missing ';' before identifier 'cout'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(31) : error C2146: syntax error : missing ';' before identifier 'vector_c'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(31) : error C2146: syntax error : missing ')' before identifier 'i'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(31) : error C2059: syntax error : ';'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(31) : error C2059: syntax error : ')'
1>d:\my documents\programming\assignments\assignment 3\p6.8\p6.8\p6.8.cpp(32) : error C2146: syntax error : missing ';' before identifier 'cout'