Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Print triangle of star/blank inside the rectangle of char

Thread view: 
unixdomain@gmail.com - 28 Mar 2007 17:26 GMT
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
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.
Oliver Wong - 28 Mar 2007 19:18 GMT
> Hello,
> I want to print a triangle, made of blanks or asterics inside a
[quoted text clipped - 26 lines]
>
> 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

   - Oliver
Lew - 29 Mar 2007 00:05 GMT
>> Hello,
>> I want to print a triangle, made of blanks or asterics inside a
[quoted text clipped - 29 lines]
>     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
Lew - 29 Mar 2007 22:26 GMT
> Hello,
> I want to print a triangle, made of blanks or asterics inside a
[quoted text clipped - 26 lines]
>
> Plz help.

Just so everyone knows, this was multiposted on the thread "Re: Print Triangle
inside a rectangle" on clj.help started on 2007-03-29.

To the OP - Please do not multi-post. If you must reach multiple groups,
please cross-post instead up multi-posting. The latter makes the answers hard
to spot, causes people to duplicate effort and generally makes life harder for
those interested in your question, including yourself.

-- Lew


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.