# Checking two arrays...

• 06-15-2006
Argo_Jeude
Checking two arrays...
How to make so that numbers in two arrays are placed in third array but sorted?
I used bubblesort,but I have to do it without it.
Exmpl.:
(Elements in first and second array must be sorted from user)
A=1,3,4,7,8
B=1,4,5,6,9
C=1,1,3,4,4,5,6,7,8,9
• 06-15-2006
karas
Algorithm called Merge sort does exactly this.
• 06-15-2006
Micko
Well if first and second array are sorted then this will give you what you want (small example assuming total 10 elements):
Code:

```int i = 0, j = 0, k = 0;         while ( k < 10 )     {         if (arr1[i] < arr2[j])         {             arr3[k++] = arr1[i++];         }         else         {             arr3[k++] = arr2[j++];         }     }```
Cheers!

- Micko
• 06-15-2006
karas
Da svi mi batalimo engleski? :)
• 06-15-2006
Micko
Haha, moze, ali mislim da se moderatorima nece svidjeti.

It's ok with me, but I don't think moderators would love it.
• 06-15-2006
karas
I said that, because this girl also speaks our language.:)
• 06-16-2006
Argo_Jeude
Quote:

Originally Posted by karas
I said that, because this girl also speaks our language.:)

Nadam se da ne misliš na mene?!
Zar nema pod kakvim opcijama da se stavi "MALE".
• 06-16-2006
Argo_Jeude
Quote:

Originally Posted by Micko
Well if first and second array are sorted then this will give you what you want (small example assuming total 10 elements):
Code:

```int i = 0, j = 0, k = 0;         while ( k < 10 )     {         if (arr1[i] < arr2[j])         {             arr3[k++] = arr1[i++];         }         else         {             arr3[k++] = arr2[j++];         }     }```
Cheers!

- Micko

Hvala!
Pokušat ću!

P.S.
A ja mislio ja jedini Bosanac ovdje!

TRANSLATION:

Thanks!
I'll try!

P.S.
And I (thinked?) I was only Bosnian here!
• 06-16-2006
King Mir
You could just use vectors and their sort meathod.
• 06-16-2006
Mario F.
Quote:

Originally Posted by Argo_Jeude
TRANSLATION:

Thanks!
I'll try!

Uuf! for a moment there I thought you people were making fun of me.