merge arrays

No replies
Offline
Last seen: 1 year 16 weeks ago
Joined: 01/25/2011
Posts:

class mergeing
{
public void merge(int[] A, int[] B, int[] C) {

int i, j, k, m, n;

i = 0;

j = 0;

k = 0;

m = A.length;

n = B.length;

while (i < m && j < n) {

if (A[i] <= B[j]) {

C[k] = A[i];

i++;

} else {

C[k] = B[j];

j++;

}

k++;

}

if (i < m) {

for (int p = i; p < m; p++) {

C[k] = A[p];

k++;

}

} else {

for (int p = j; p < n; p++) {

C[k] = B[p];

k++;

}

}

}
psblic static void main(String args[])
{
mergeing obj=new mergeing();
obj.merge();
}
}

tim.speed's picture
Offline
Last seen: 17 hours 39 min ago
Joined: 02/24/2010
Posts:
Interesting, what is this

Interesting, what is this for?
Is there an issue with it?
Your obj.merge() is missing the array parameters.

-----------------
Tim Speed
Compilr Developer and CTO