Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delete repeated entries in array
#2
Macro Macro2373
Code:
Copy      Help
out
ARRAY(int) a b
int i j

;create array a for testing
out "array a:"
a.create(10)
for(i 0 a.len) a[i]=RandomInt(0 a.len/2); out a[i]

;create array b from unique elements of array a
for i 0 a.len
,int& r=a[i]
,for(j b.len-1 -1 -1) if(b[j]=r) break
,if(j<0) b[]=r

out "array b:"
for(i 0 b.len) out b[i]


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)