Merging of two arrays

sekhar_529's Avatar
Light Poster
Merging of two arrays and sort it wthout using third array?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by sekhar_529
Merging of two arrays and sort it wthout using third array?
Did you start on the topic or want someone to complete the job and deliver it into your inbox.
sekhar_529's Avatar
Light Poster
I dont know how to do,Plz give program and explanation.
sekhar_529's Avatar
Light Poster
I want someone to complete the job.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by sekhar_529
I want someone to complete the job.
Try the jobs forum then.
ahmmad's Avatar, Join Date: Aug 2010
Newbie Member
Quote:
Originally Posted by sekhar_529 View Post
Merging of two arrays and sort it wthout using third array?
Code:
public class Merge3
{
    public static void main(String[] args)
    {
        int[]A = {1,2};
        int[]B = {7,8,9};
        int[]C = new int[A.length + B.length];

        int a = 0;
        int aCount = A.length;
        int bCount=B.length;
        int c = C.length;



        while (a < aCount)
        {

            if(A[a] < B[a])

                 C[a]= A[a];
                 else

                 C[a]=B[a];

            a++;

        }



        for(int b1 = 0; b1 < B.length; b1++){
            C[a] = B[b1];
            a++;
        }

        for (int i = 0; i < C.length; i++){
            System.out.println(C[i]);
        }

    }
}

Last edited by shabbir; 4Aug2010 at 11:43.. Reason: Code Block
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
Originally Posted by sekhar_529 View Post
Merging of two arrays and sort it wthout using third array?
and the programming language is......
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
Originally Posted by ahmmad View Post
Code:
public class Merge3
{
    public static void main(String[] args)
    {
        int[]A = {1,2};
        int[]B = {7,8,9};
        int[]C = new int[A.length + B.length];

        int a = 0;
        int aCount = A.length;
        int bCount=B.length;
        int c = C.length;



        while (a < aCount)
        {

            if(A[a] < B[a])

                 C[a]= A[a];
                 else

                 C[a]=B[a];

            a++;

        }



        for(int b1 = 0; b1 < B.length; b1++){
            C[a] = B[b1];
            a++;
        }

        for (int i = 0; i < C.length; i++){
            System.out.println(C[i]);
        }

    }
}

you used 3 arrays.The question was without a third array