Hi Lan
Sounds like this is an Algorithm question :)
I'm still not very sure about the exact result you want.
My understanding is you have a source array which may contains a large
sequence of elements. And a certain sub sequence of elements in the array
are of the same group(according to their index in array or their value?)
and you want to extract them out from the array and make the elements of
the same group together, correct?
As Tomb mentioned the "two-dim" array approach, I also think this is a good
idea if the interval or size of each group are fixed. You can create a
two-dimensional array in your code and copy all the elements from original
array into the two dimensional array.
Also, I think it would be helpful you provide more info such as some
example data(what's the original array and what you want to make them be
tranformed into and how you will use them after transformed). Thus, we can
look for some further ideas on this.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
\\
>From: =?Utf-8?B?aWxy?= <il*@noemail.noemail>
References: <F7**********************************@microsoft.co m>
<_T*******************@bignews7.bellsouth.net>
>Subject: Re: Extract data from arrays
Date: Thu, 7 Feb 2008 20:39:00 -0800
\
>
Thanks for replying tomb.
The array is returned from a 3rd pary library so I don't really have much
choice in that respect.
"tomb" wrote:
>If the elements are always 10, or some such number, that are related,
why not use a multi dimensional array instead?
T
ilr wrote:
Hi
This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.
I have an array with a large number of elements in it. 0-9 are
related
data, 10-19, 20-29 are related and so on. What is the best way of
extracting
groups of elements from the array into another array where each
element is
the related data or to extract say elements 0,1,5 from the first
group,
10,11,15 from the second etc.
I have tried iterating through the array with if then statements but
for a
large array this gets messy.
Any advice would be greatly appreciated.
Regards
Ian