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.
...
Type: Posts; User: Genky
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.
...
Thank you very much, I see what I need to do. It seems hard but I will try.
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*.
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...
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.
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 <...
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,...
-The first line it prints one *, spaces = number row - number of *
- Each line decrease number of * by 2.
You mean like this
for (int i = 0; i <4; i++) {
System.out.print(" ");
for (int j = 0; j < 4; j++) {
System.out.print("*");
}...
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...
I saw there are 4 lines. Each line the number of spaces decrease by one, and the number of * increase 1,3,5,7.
I mean I was required to show a isoceles triangle. But I don't know how to edit it in above post.
I need a triangle like this
*
***
*****
*******