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 [email protected]
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