Print triangle of star/blank inside the rectangle of char

Discussion in 'Java' started by unixdomain@gmail.com, Mar 28, 2007.

  1. Guest

    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.
    , Mar 28, 2007
    #1
    1. Advertising

  2. Oliver Wong Guest

    <> wrote in message
    news:...
    > 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
    Oliver Wong, Mar 28, 2007
    #2
    1. Advertising

  3. Lew Guest

    Oliver Wong wrote:
    > <> wrote in message
    > news:...
    >> 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
    Lew, Mar 29, 2007
    #3
  4. Lew Guest

    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
    Lew, Mar 29, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. km
    Replies:
    0
    Views:
    388
  2. VISHNU VARDHAN REDDY UNDYALA

    program to print a triangle of astericks

    VISHNU VARDHAN REDDY UNDYALA, Oct 28, 2005, in forum: C Programming
    Replies:
    17
    Views:
    1,831
    Joe Wright
    Nov 1, 2005
  3. lovecreatesbeauty
    Replies:
    1
    Views:
    1,046
    Ian Collins
    May 9, 2006
  4. Replies:
    2
    Views:
    113
  5. Nikhil Joshi

    Write a program to print star using * ?

    Nikhil Joshi, Oct 23, 2012, in forum: C Programming
    Replies:
    9
    Views:
    594
    Nick Keighley
    Oct 27, 2012
Loading...

Share This Page