I have to write two arrays of 10 random numbers betwwen 1 and 25 then sort those two arrays in increasing order then make a third array that has all the numbers of the first two arrays in sorted order but no duplicate numbers in the third array.
Here are my function prototypes:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void rand_gen(int a[], int size);
void sorting(int a[], int size);
int linear_search(int a[], int size, int key);
void print_out(int a[], int size);
void merge(int a[], int b[]);
Here is my main function:
#include "lab10_1.h"
int main()
{
const int max=20;
int a[max], b[max];
srand(time(0));
rand_gen(a, 10);
cout<<"\nArray 1 is the following: \n";
print_out(a, 10);
sorting(a, 10);
cout<<"\nArray 1 in increasing order: \n";
print_out(a, 10);
rand_gen(b, 10);
cout<<"\nArray 2 is the following: \n";
print_out(b, 10);
sorting(b, 10);
cout<<"\nArray 2 in increasing order: \n";
print_out(b, 10);
return 0;
}
And here are my functions:
#include "lab10_1.h"
void rand_gen(int a[], int size)
{
int i;
size=10;
for (i=0; i<size; i++)
a[i]=1+rand()%25;
}
void sorting(int a[], int size)
{
int i, pass, hold;
for (pass=0; pass<size-1; pass++)
{
for (i=0; i<size-1; i++)
{
if (a[i]>a[i+1])
{
hold=a[i];
a[i]=a[i+1];
a[i+1]=hold;
}
}
}
}
void print_out(int a[], int size)
{
int counter=0;
for (int i=0; i<size; i++)
{
counter++;
cout<<a[i]<<" ";
}
cout<<endl;
}
int linear_search(int a[], int size, int key)
{
int i, position=-1;
for (i=0; i<size; i++)
{
if (a[i]==key)
return i;
else
return position;
}
}
void merge(int a[], int b[])
{
// I dont know
}
So far I can create the random arrays, print them in increasing order, but i cannot make the third array and delete the duplicate numbers.
So are there any suggestions? I'm a little short on time I have finals on Weds and a 14 page paper due Tues and this code is due Tues by 8am.
Any help is appreciated...