array comparison and sort

From: vic (vivi74_at_rocketmail.com)
Date: 10/30/04


Date: 30 Oct 2004 06:41:29 -0700

Hello All,

I am running into this problem of getting my array to output the
desired results. Below is the problem

i have two string arrays via

String[] ar1 = {1,2,1,4,1,2};
String[] ar2 = {7,3,7,5,7,3};

each array contains 6 elements.

i want to do something like this

compare elements of ar1 and ar2 with one another and the moment it
encounters a true condition, e.g in the above example when

(ar1[0].equals(ar1[2])) && (ar2[0].equals(ar2[2]))

then i want to array pointer to move to ar1[1] and ar2[1] so that it
starts comparing from index->1 and same logic apllies. The output
would be something like this for the first iteration

ar1 = {2,1,4,1,2}

ar2 = {3,7,5,7,3}

now if we applied same logic in a loop output would be

ar1 = {1,4,1,2}

ar2 = {7,5,7,3}

and final output

ar1 = {4,1,2}

ar2 = {5,7,3}

The final output should have a unique set of values

Appreciate any help

thanks
vivi



Relevant Pages

  • Re: Mergring two string Arrays
    ... I've two string arrays A & B. One of it is sorted B. A is not sorted. ... I want array A to be same as array B. So I was thinking the following is ... Free games and programming goodies. ...
    (comp.lang.c)
  • Re: Mergring two string Arrays
    ... I've two string arrays A & B. One of it is sorted B. A is not sorted. ... Now I want array A to be same as array B. So I was thinking the following is the right way: ... Free games and programming goodies. ...
    (comp.lang.c)
  • Re: Mergring two string Arrays
    ... !GNITSOP-POT POTS ESAELP ... I've two string arrays A & B. One of it is sorted B. A is not sorted. ... want array A to be same as array B. So I was thinking the following is the ...
    (comp.lang.c)
  • Re: Mergring two string Arrays
    ... !GNITSOP-POT POTS ESAELP ... I've two string arrays A & B. One of it is sorted B. A is not sorted. ... want array A to be same as array B. So I was thinking the following is the ...
    (comp.lang.c)