RE: Need someone very familiar with arrays
- From: KeetClassic <KeetClassic@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 6 Nov 2007 14:55:01 -0800
"Les" wrote:
I was wondering if someone can offer me a clever way of doing the following.
Lets say I have an array like the following:
A(1) = 3
A(2) = 5
A(3) = 0
A(4) = 6
A(5) = 9
A(6) = 10
A(7) = 0
A(8) = 14
A(9) = 0
.
.
A(n)
I need a very efficient method to turn the above array into the following:
A(1) = 3
A(2) = 5
A(3) = 6
A(4) = 9
A(5) = 10
A(6) = 14
.
.
A(n)
Notice the array has been rewritten but excludes the ones that equalled
zero. Now I can do this by checking each array and rewritting it but I am
hoping that there exists a trick of the trade to do it fast. I am also
willing to consider dumping tihs array to another array if that helps you
folks out in a solution. Im hoping that there is a way to just work with the
array as a whole but lets see what you people can think of.
Keeping my fingers crossed,
Les
Hi Les,
First of all I want to apologize on behalf for everyone that has responded
and made what should be very simple into something that became a complicated
headache... (a Linked List for THIS, gimme a break!)
So, it's clear you are not sorting, just shuffling down to get rid of the 0
value gaps... you should keep the original array as you preferred. The ONLY
question is whether you want to redimension your array bounds or keep all the
zeros at the end?
It looks to me like Robert Morley already solved this in his first post,
except I would have done it slightly different because if your first value
happens to be a zero it would be missed :P (Sorry Rob)
.
- Follow-Ups:
- Re: Need someone very familiar with arrays
- From: Robert Morley
- Re: Need someone very familiar with arrays
- From: Mike Williams
- Re: Need someone very familiar with arrays
- From: Mike Williams
- Re: Need someone very familiar with arrays
- From: dpb
- Re: Need someone very familiar with arrays
- Prev by Date: Re: Why windows is so beautiful?
- Next by Date: Re: Need someone very familiar with arrays
- Previous by thread: TLBINF32.DLL : name of coclass member
- Next by thread: Re: Need someone very familiar with arrays
- Index(es):
Relevant Pages
|
Loading