Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Print triangle of star/blank inside the rectangle of char

Reply
Thread Tools

Print triangle of star/blank inside the rectangle of char

 
 
unixdomain@gmail.com
Guest
Posts: n/a
 
      03-28-2007
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.

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      03-28-2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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.
>


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


 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      03-28-2007
Oliver Wong wrote:
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
>> 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.
>>

>
> 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
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-29-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
> 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.


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
Rectangle inside a tooltip km Java 0 04-11-2006 05:17 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
How to print a rectangle construct variabe in JavaScript? cjeffwang@gmail.com Javascript 2 11-06-2005 05:51 AM
Canvas - Rectangle. Is there an easy way to detect if you're inside? Marc Python 5 09-12-2003 04:14 PM



Advertisments