Re: Print Triangle inside a rectangle
- From: RedGrittyBrick <RedGrittyBrick@xxxxxxxxxxxxx>
- Date: Thu, 29 Mar 2007 23:15:25 +0100
unixdomain@xxxxxxxxx wrote:
Hello,
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
Why are the assignments to j and row in comments?
I can't just use use copy and paste to run your code, you're making it hard work for anyone who wants to help.
Read these:
http://homepage1.nifty.com/algafield/sscce.html
http://mindprod.com/jgloss/sscce.html
for(int c=0;c<arr.length;c++) //char
arr[]={'A','B','C','D','E','F','G','F','E',.....};
Those "...." don't look like valid Java.
Regularly posted to this newsgroup is a message on how to get the best out of it. It says
Before posting read Jon Skeet's "How to get answers on the
comp.lang.java.* newsgroups" at
http://www.pobox.com/~skeet/java/newsgroups.html
if(c==maxCol) //int maxCol=6;
arr[c]=b; //char b = ' ';
----------------------------------------------------
_FROM THIS POINT I CAN'T PROCEED!____________________________
Why not?
- do you get a compiler error message?
- do you get a run-time error?
- how does the output differ from what you want
for(blank=0;blank<maxBlank;blank++)
arr[blank]=b;
maxBlank+=2;
maxCol--;
row++;
j++;
}while(j<=6);
Plz help.
Here's what *not* to do
http://www.catb.org/~esr/faqs/smart-questions.html#homework
Here's how to solve this problem
http://home.earthlink.net/~patricia_shanahan/beginner.html
I'd try asking a more narrowly focused specific question.
.
- References:
- Print Triangle inside a rectangle
- From: unixdomain
- Print Triangle inside a rectangle
- Prev by Date: Re: JSP problem..
- Next by Date: Re: problem with applet access to web service
- Previous by thread: Print Triangle inside a rectangle
- Next by thread: io: how many imgs in 'images' folder?
- Index(es):
Relevant Pages
|