Showing error java.util.nosuchelementexception but running on eclipse

import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n= scn.nextInt();
int nst=1;
int num=1;
for(int row=1;row<=n;row++){
System.out.println();
for(int col=1;col<=nst;col++){
if(row%2!=0||col==1||row==col){
System.out.print(num);

}else{
	System.out.print("0");
	}

}
nst=nst+1;
}

}

}

@Shivam_balwani,
there seems to be an error in your code as well.

In the given pattern if row number is n (>1), total character is n. First and last character is n-1 and rest are 0.

Also, you can refresh the page and try to submit again. If the problem persists kindly write an email to [email protected]