If 5
is inserted in sc.input
below:
*
***
*****
but, I got below:
*
***
*****
What's the problem?
public void test3() {
Scanner sc = new Scanner(System.in);
int n1 = sc.nextInt();
for(int i=0; i<n1; i++){
if(i<=n1/2){
for(int j=0; j<n1; j++) {
if( j<(n1/2)-i || j>(n1/2)+i ) {
for(int m=0; m<(n1/2)-i; m++){
System.out.print(" ");
}
} /*else if( j==2 ) {
System.out.print("*");
}*/ else {
System.out.print("*");
}
}
System.out.println();
}
}
}