+ 1
Left Triangle Star Pattern Output Problem
I don't know why it's not working! Please someone help me.Here is my code. https://code.sololearn.com/c1s5Ci16iGz8/?ref=app
12 odpowiedzi
+ 2
Coding Cat this is Right triangle
+ 2
Jayakrishna🇮🇳 Result of my code
+ 1
Time To Code I want to print left triangle. That's means left side space then something. And right side will be equal.
if 1st row have 3 space then 2nd will be 2 space, 3rd will be 1 space and last one have no space.
+ 1
Sorry, I know, it's solved. But I want to do that with only one single loop. And now I'm ready 😉
https://code.sololearn.com/cFxRQNs9H45F/?ref=app
0
Its working... What is the you getting?
0
*
* *
* * *
* * * *
* * * * *
Almost Like this. Jayakrishna🇮🇳
0
Remove a space .. use this
System.out.print("* "); //no space before it in line no: 17
edit:
Milon
if you don't want space at start, then comment
System.out.print(" "); // in inner first loop..
for(int row=1; row<=n; row++){
// Number Printing
for(int col=1; col<=row; col++){
System.out.print("* ");
}
//Printing New Line
System.out.println(" ");
}
0
Jayakrishna🇮🇳 output is now Pyramid🙃
0
Now check my last post edit .
edit:
Remove first inner loop ..
then try this :
for(int row=1; row<=n; row++){
// Number Printing
for(int col=1; col<=row; col++){
System.out.print("* ");
}
//Printing New Line
System.out.println(" ");
}
edit:
Milon
the pattern you posted above is your expected one or the result of code?
0
Oh try this:Milon
for(int row=1; row<=n; row++){
// Space printing
for(int col=1; col<= n-row; col++){
System.out.print(" "); //double space
}
// Number Printing
for(int col=1; col<=row; col++){
System.out.print(" *"); //no space after
}
//Printing New Line
System.out.println(" ");
}
0
Jayakrishna🇮🇳 Already try this. But didn't work. I'm coding with my phone. That's why i can't solve this. Thanka bro.
0
I Solved it. Now it's working. Thanks Everyone.