well, if u want to fill up large arrays several times, then u can make
a bit faster using memset(....) function of the c++ string library to
fill up the '-' s .
then as there will be less '*' s then '-' s u can do it (fill up the
with the '*' s )
using nested loop
-Minhaz


On 1/25/07, delboy <[EMAIL PROTECTED]> wrote:
>
> Thanks Aakash, excellent work.
>
> On Jan 25, 4:39 am, "aakash mandhar" <[EMAIL PROTECTED]> wrote:
> > for(int i=0;i<=n/2;i++)
> > {
> > for(int j=0;j<=i;j++)
> > {
> >  a[i][j]=='*';}for(int j=i+1;j<n;j++)
> > {
> >  a[i][j]=='-';
> >
> > }
> > }for(int i=n/2+1;i<n;i++)
> > {
> > for(int j=0;j<=(n-i);j++)
> > {
> >  a[i][j]=='*';}for(int j=(n-i)+1;j<n;j++)
> > {
> >  a[i][j]=='-';
> >
> > }
> > }Where a is the result array
> >
> > R,
> > Aakash
> >
> > On 1/24/07, delboy <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > OK, I need to write an algorithm to populate a 2D array A(i,j) of size
> > > n x n. There is 1 '*' in the 1st row, increasing to n/2 in the middle
> > > row, this decreases back to 1'*' in the last row. We can also assume
> > > that n is odd.
> >
> > > *----------
> > > **---------
> > > ***-------
> > > ****------
> > > *****-----
> > > ****------
> > > ***-------
> > > **---------
> > > *----------
> >
> > > Hope this clarifies things,
> >
> > > Del.
> >
> > > On Jan 24, 4:06 pm, "Sandesh" <[EMAIL PROTECTED]> wrote:
> > > > Not clear,
> > > >         give the full explanation .........
> > > >     Sandesh Hegde
> >
> > > > On Jan 24, 8:32 pm, "delboy" <[EMAIL PROTECTED]> wrote:
> >
> > > > > Hi,
> >
> > > > > I'm trying to input the following values into a 2D array via some
> sort
> > > > > of method / algorithm. Any ideas on the best way to approach this?
> >
> > > > > *----------
> > > > > **---------
> > > > > ***-------
> > > > > ****------
> > > > > *****-----
> > > > > ****------
> > > > > ***-------
> > > > > **---------
> > > > > *----------
> >
> > > > > Thanks,
> > > > > Del
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to