Now Ineed help combining arrays. Please help.

Here's the code Ihave so far.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int findmax (int a1[45], int a2[50], int i, int j);
int findmin (int a1[45], int a2[50], int i, int j);


int main(void)

{

	unsigned seed = time (0);

	srand(seed);

	cout<<"First Array"<<endl;

	int a1[45];
		for (int i = 0; i < 45; i++)
     a1[i] = 1 + rand () % 45;

	cout <<a1[i]<<endl;}

	cout<<"Second Array"<<endl;

	int a2[50];
for (int j = 0; j < 50; i++)
     a2[j] = 1 + rand () % 50;

if (a2[j] % 5 ==0)

cout<<a2[j]<<endl;}

cout<<"Third Arrary"<<endl;

cout<<max1<<endl;

cout<<"Forth Arrary"<<endl;

cout<<max2<<endl;

cout<<"Fifth Array"<<endl;

cout<<min1<<endl;

int findmax(int a1[i], int i)
  {
       int max1;
       min = 1; 
       for (i=0; i<45; i++)
           {
                  if(a1[i] > min)
                     max1=a1[i];
                      
           }
       return max1;
  }

int findmax(int a2[j], int j)
  {
       int max2;
       min = 1; 
       for (j=0; j<50; j++)
           {
                  if(a2[j] > min)
                     max2=a1[j];
                      
           }
       return max2;
}


 int findmin(int a1[i], int i)
  {
       int i, min1;
       min = 45;
       for (i=0; i<45; i++)
           {
                  if(a1[i] < min)
                     min1=a1[i];
                      
           }
       return min1;
  }

 int findmin(int a2[j], int j)
  {
       int min2;
       min = 50; 
       for (j=0; i<50; j++)
           {
                  if(a2[j] < min)
                     min2=a2[j];
                      
           }
       return min2;
  }

Reallocate pointer1 to size of itself plus pointer2, then memmove() p2 to the end of p1.

or like this, when done the vector will contain the contents of both int arrays.

int main()
{
    int a1[45];
    int a2[45];
    int x = 0;
    vector<int> v1( (sizeof(a1)/sizeof(a1[0])) + sizeof(a2)/sizeof(a2[0]) );
    for(int i = 0; i < sizeof(a1)/sizeof(a1[0]); i++)
        v1[i] = a1[i];
    for(int i = 0; i < sizeof(a2)/sizeof(a2[0]); i++)
        v1[i] = a2[i];
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.