You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Derry <dd...@acm.org> on 2002/10/28 13:21:09 UTC

Re:[OT] Trivial Q

This will work some of the time (maybe most). But you are missing edge
conditions. take 8 for ex. in a 4X4 that would be row 2 column 4. But your
foumula places it at row 3 column 0. However, right now I can't think of a
better solution (too early on a Mon morning!), other than to test for column
== 0, in which case --row; column = numberOfColumns.

Dave D


----- Original Message -----
From: "Vincent PROSPER" <Vi...@Alkinos.com>


> oops!
>
> replace 'nb_rows' by 'nb_cols' in first instruction... nb_rows has nothing
> to do with that question...
>
> Vince
>
> -----Original Message-----
> From: Vincent PROSPER [mailto:Vincent.Prosper@Alkinos.com]
>
>
> col=number % nb_rows ;
> row=(number / nb_cols) + 1; // provided that number and nb_cols are both
int
>
> Vince
> -----Original Message-----
> From: Khan, Manuchehar A (ACF) [mailto:mkhan@acf.hhs.gov]
> Sent: Monday, October 28, 2002 9:30 AM
> To: 'Struts Users Mailing List'
> Subject: RE: Trivial Q
>
>
> Java
>
> -----Original Message-----
> From: Vincent PROSPER [mailto:Vincent.Prosper@Alkinos.com]
>
> if number=10 (for instance) for an array nb_cols x nb_rows then
>
> col=number mod nb_rows       (should be 2)
> row=(number div nb_cols) + 1 (should be 3)
>
> dont know the language you're looking for ;-)
>
> Vince
>
> -----Original Message-----
>
>
> This q is irrelevant to strusts but somebody can solve this easy puzzle
that
> I am stuck with....
> I have an multidimentional array rows*columns....Can someone figureout
code
> to get the x, y poisition in this multidimentional array if i know the
> number....
>
> For example I have number 10.....Its position in array for size (4X4) will
> be 3rd row and 2nd column...
> What will be the code to get number when size of array of number change
> dynamically...
>
> Thanks



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>