hello all i managed to create two arrays and sort then in to one array in order but now i cant figure out a code to delete any duplicates. below void loop is my prototype function that arranged it.
/*
* Ruben Padilla
* 11/7/20
* lap11p3
* Assort rays no duplicate
*/
void combine_arr(int x[], int NX, int y[], int NY, int z[]);
void setup()
{
delay(3000);
Serial.begin(115200);
int NX=6,NY=6;
int x[NX] = { -1, 6, 14, 19, 33,44};
int y[NY] = { -1, 16, 18, 32, 55, 99};
int z[NX + NY], i;
combine_arr(x, NX, y, NY, z);
for (i = 0; i < (NX + NY); i++)
{
Serial.print(z[i]); Serial.print(", ");
}
}
void loop()
{
}
void combine_arr(int x[], int NX, int y[], int NY, int z[])
{
int i, j, k;
j = 0; k = 0;
for (i = 0; i < NX + NY;)
{
if (j < NX && k < NY)
{
if (x[j] < y[k])
{
z[i] = x[j];
j++;
}
else
{
z[i] = y[k];
k++;
}
i++;
}
else if (j == NX)
{
for (; i < NX + NY;)
{
z[i] = y[k];
k++;
i++;
}
}
else
{
for (; i < NX + NY;)
{
z[i] = x[j];
j++;
i++;
}
}
}
}