Re: Print triangle of star/blank inside the rectangle of char
- From: Lew <lew@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Mar 2007 19:05:31 -0400
Oliver Wong wrote:
<unixdomain@xxxxxxxxx> wrote in message news:1175099209.326856.35070@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHello,
I want to print a triangle, made of blanks or asterics inside a
rectangle made of alphabets.
It's as follows;
ABCDEFGFEDCBA
ABCEEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
It has 7 rows and 13 columns. I tried to implement like this;
do {
if(j == rows) //int j=0, int row=1
for(int c=0;c<arr.length;c++) //char
arr[]={'A','B','C','D','E','F','G','F','E',.....};
if(c==maxCol) //int maxCol=6;
arr[c]=b; //char b = ' ';
----------------------------------------------------
_____________________________
for(blank=0;blank<maxBlank;blank++)
arr[blank]=b;
maxBlank+=2;
maxCol--;
row++;
j++;
}while(j<=6);
Plz help.
I don't know about the others here, but I'd be more willing to help if you posted an SSCCE: http://mindprod.com/jgloss/sscce.html
Doesn't this question or one much like it hit the group every semester?
Hint to the OP: Not only should your code be a complete example (the code you presented will not compile), but it helps those who might help you to format the code you post to the group according to the Sun conventions or close to them.
If this is homework, don't expect people here to help you cheat. You can get help even in that case, by admitting that it's homework and presenting a complete example as Oliver suggested.
-- Lew
.
- References:
- Print triangle of star/blank inside the rectangle of char
- From: unixdomain
- Re: Print triangle of star/blank inside the rectangle of char
- From: Oliver Wong
- Print triangle of star/blank inside the rectangle of char
- Prev by Date: Re: Resolving fully qualified name?
- Next by Date: Re: SAX PARSING DESIGN PATTERN
- Previous by thread: Re: Print triangle of star/blank inside the rectangle of char
- Next by thread: Help regarding Posting of Java Job requirements in USA
- Index(es):