Hello Buddy,
I am trying to solve that Pattern but i am facing some but i am facing small issue, i completed 95% of pattern but in this pattern oneside there is decrement of values is there, that i am not getting that please help.
Ref: https://ide.codingblocks.com/s/278076
Pattern InvertedHourGlass
@s.v,
Are you sure you shared the correct code? Because this looks like the code for Pythagoras triplets.
@s.v,
https://ide.codingblocks.com/s/278670 corrected code.
Errors:
I changed the code snippet:
int value = 1, x = n-noOfStars +1;
while (checkStars1 <= noOfStars) {
if (row == n) {
System.out.print(value + " ");
} else {
System.out.print(x + " ");
}
checkStars1++;
value++;
x++;
}
and
int checkStarsDown1 = 1, y = n-noOfStarsDown+1;
while (checkStarsDown1 <= noOfStarsDown) {
System.out.print(y + " ");
checkStarsDown1++;
y++;
}
We will start from n-stars+1 instead of n.
Alternate approach: https://ide.codingblocks.com/s/278671