Merging Functions. Help on the main?

So as far as i know I got my function working but i'm stuck on how to implement it in main. Help please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <vector>
#include <iostream>
using namespace std;

vector<int> interlace_vectors(const vector<int>& v1, const vector<int>& v2)
 {
      vector<int> result;
      for(size_t n = 0; n < max(v1.size(), v2.size()); ++n)
      {
           if(n < v1.size()) result.push_back(v1[n]);
           if(n < v2.size()) result.push_back(v2[n]);
      }
      return result;
 }
 
 int main()
 {
     int v1[5] = {4,7,9,3,1};
     int v2[3] = {3,6,9};
     
     for (int i; i  
     system ("pause");
     return 0;
 }
Create two vectors in main() then call the function, passing them as parameters.
I've been trying that and I can't get it to work. What am I missing? I'm sure it's a noobish question but I just don't know what to do.
1
2
3
4
5
6
7
8
 int main() 
 {
     int v1[5] = {4,7,9,3,1};
     int v2[3] = {3,6,9};
     cout << interlace_vectors  (v1, v2) << endl; 
     system ("pause");
     return 0;
 }
Can someone help me please??
the function returns a vector, so initialize one:

1
2
3
4
5
6
7
8
9
int main() 
{
     vector<int> v1 = {4,7,9,3,1};
     vector<int> v2 = {3,6,9};
     vector<int> v3 = interlace_vectors(v1, v2);
     for(int n: v3)
         cout << n << ' ';
     cout << '\n';
}

online demo: http://ideone.com/l3f5mO
Topic archived. No new replies allowed.