whats wrong in my code
Question
Pattern with Zeros
Take N (number of rows), print the following pattern (for N = 5)
1
2 2
3 0 3
4 0 0 4
5 0 0 0 5
Input Format:
Constraints:
0 < N < 100
Solution
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i=1;i<=n;i++){
//for(int j=1;j<=i;j++){
if(i>n/2){
System.out.print(i);
for(int k=1;k<=i-2;k++){
System.out.print(“0”);
}
System.out.print(i);
}
else{
for(int j=1;j<=i;j++){
System.out.print(i);
}
}
//}
System.out.println();
}
}
}