thomas_dipu
March 27th, 2001, 09:47 PM
Hi There,
U might find this silly, I am stuck with one thing.WEll I have this
problem I have this array a[n] = [1,2,2,1,3,3,4,4,5,6]
I just want to remove the duplicates and get the o/p as [1,2,3,4,5,6],
this is to be stored in an array X[]
What I tried is like this
for i = 0 to n
for j = i + 1 to n
if a[i] != a[j] then
x[j] = a[i]
end if
next j
next i
The problem with the above is that it will print the dissimilar numbers
more than once like 1,2,1 etc etc.
NOTE - PLS READ BELOW ALSO
The following is the exact scenario, I am using VB to compare, but the logic should be same, so I welcome any suggestions
I am already sorting the o/p, thru my SQL. This is the O/p from the SQL.
ID Comments
5 This is Test5a <--
5 This is Test5b
5 This is Test5c
5 This is Test 5b
1 This is Test 1a <--
1 This is Test 1b
1 This is Test 1c
From the above O/P I should be able to filter the arrow ones into an array.
The o/p should show only the arrow ones , Meaning I only have to compare for the ID, If it is not equal just display the first one.
O/p
5 This is Test5a
1 This is Test1a
I would really appreciate if somebody is able to help
Thanks
Dipu Thomas
U might find this silly, I am stuck with one thing.WEll I have this
problem I have this array a[n] = [1,2,2,1,3,3,4,4,5,6]
I just want to remove the duplicates and get the o/p as [1,2,3,4,5,6],
this is to be stored in an array X[]
What I tried is like this
for i = 0 to n
for j = i + 1 to n
if a[i] != a[j] then
x[j] = a[i]
end if
next j
next i
The problem with the above is that it will print the dissimilar numbers
more than once like 1,2,1 etc etc.
NOTE - PLS READ BELOW ALSO
The following is the exact scenario, I am using VB to compare, but the logic should be same, so I welcome any suggestions
I am already sorting the o/p, thru my SQL. This is the O/p from the SQL.
ID Comments
5 This is Test5a <--
5 This is Test5b
5 This is Test5c
5 This is Test 5b
1 This is Test 1a <--
1 This is Test 1b
1 This is Test 1c
From the above O/P I should be able to filter the arrow ones into an array.
The o/p should show only the arrow ones , Meaning I only have to compare for the ID, If it is not equal just display the first one.
O/p
5 This is Test5a
1 This is Test1a
I would really appreciate if somebody is able to help
Thanks
Dipu Thomas