Quote (carteblanche @ Sep 26 2013 07:29pm)
if you dont even need to sort it, should be simple. in pseudo code
Code
mergedarray = new array[array1.size + array2.size];
for i = 0 to array1.size
mergedarray[i] = array1[];
for i = 0 to array2.size
mergedarray[i+array1.size] = array2[i]
That is Java, not C. And really Pseudocode is as useful as a lit candle up your ass. I never understood the point of writing extra stuff of "this is how I am going to do something" instead of just fucking doing it.
Arrays in C are declared as type name[size]; ex. int somearray[20];
Only thing you need to do here is to declare a new array c that's the size of a+b so in this case it will be 15 and use a for loop to feed the elements into it, like:
int c[15]; //or c[a.size()+b.size()]; //(if this gives you compiler errors then add #include <array> to the top of the program, between #include <iostream> and using namespace std;
for(int i=0;i<15;i++){
if(i<10) c[i] = a[i];
else c[i]=b[i-10];
}
or do something like this if you want a more general loop:
c[a.size()+b.size()];
for(int i=0;i<a.size()+b.size();i++){
if(i<a.size()) c[i] = a[i];
else c[i]=b[i-a.size()];
}
This post was edited by NeX_1337 on Sep 30 2013 03:34am