What is wrong in my logic of given pattern

Scanner scn = new Scanner(System.in);
int n=scn.nextInt();
int row=1;
while(row<=n) {
for(int i=1;i<=row;i++) {
if(row<=n/2) {
System.out.print(“1”);

			}
			else {
				if(i>1&&i<row) {
					System.out.print("0");
			}
				else {
					int row1=row-1;
					System.out.print(row1);
				}
			}
				System.out.println();
				row=row+1;
		}
	}

}

}

Hi Shivendra,
See in this question, you can see the pattern from second row i.e. first and last character will be row -1 and in between characters are 0. 1st row always contain only 1 no matter what the total rows are.