Search:

Type: Posts; User: Genky

Search: Search took 0.20 seconds.

  1. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    Thank you very much, you are so cool :cool::cool:. I did it after some papers. I'm so happy. Now I understand the feeling of solving a problem by working through it. Thank you many times.



    ...
  2. Replies
    13
    Views
    8,945

    Sticky: Re: The Problem with Spoon-feeding

    Thank you very much, I see what I need to do. It seems hard but I will try.
  3. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    This is the out put:

    **
    ***
    ****
    *****

    The problems is : The space doesn't show correct.

    I mean I've increased number of * each time in for loop = * + 2*.
  4. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    I searched and wrote code for print space like this:

    String space = String.format("%" + (n-1) + "s"," ");

    But it just prints 4 space. I don't know why.


    Please explain what the problem...
  5. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    It didn't run in this line System.out.printf("%",spa," "); . Can you correct for me?
    And int numsta =i+2 does not bring correct result.
  6. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    int n = 4;
    for(int i =0; i<n;i++){
    int space = n-1;
    System.out.printf("%",spa," ");//want to print number of spaces
    int numsta =i+2;//but it's not true
    for (int j = 0; j <...
  7. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    You're so patient.


    The first line has 3 spaces, one *
    The second line has 2 spaces, three ***
    The second line has 1 spaces, five *****
    The second line has 0 spaces,...
  8. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    -The first line it prints one *, spaces = number row - number of *
    - Each line decrease number of * by 2.
  9. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    You mean like this

    for (int i = 0; i <4; i++) {
    System.out.print(" ");
    for (int j = 0; j < 4; j++) {
    System.out.print("*");
    }...
  10. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    for (int i = 0; i <4; i++) {
    System.out.printf("%" + i + "s", "");
    for (int j = 0; j < 4; j++) {
    System.out.print("*");
    }
    System.out.println();
    }


    But I don't know...
  11. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    I saw there are 4 lines. Each line the number of spaces decrease by one, and the number of * increase 1,3,5,7.
  12. Replies
    26
    Views
    1,309

    Re: Print out a triangle by character *

    I mean I was required to show a isoceles triangle. But I don't know how to edit it in above post.
  13. Replies
    26
    Views
    1,309

    Print out a triangle by character *

    I need a triangle like this





    *
    ***
    *****
    *******
Results 1 to 13 of 13