Error while running code

same code has run for the first time and completed all testcases but when i tried this code for the next time it giving me error and the same error is coming for all other code i attempting on coding blocks platform and all the codes are running error
free on online gdb and other platforms .
error- Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Manmohan.main(Manmohan.java:6)

please review as soon as possible

Hi @uttkarsh17goswami,
Please save your code on online ide ide.codingblocks.com and send the url.

import java.util.*;
public class Manmohan {
public static void main(String args[]) {

Scanner scn = new Scanner(System.in);
int n = scn.nextInt();

int row = 1;
int nst=1;
int val=1;

while(row<=n){
int a=row;

int b=a-1;
for(int cst=1;cst<=nst;cst++){
if(nst<3)
System.out.print(val);
else{
val++;
if(cst==1 || cst==row)
System.out.print(b);
else
System.out.print(“0”);
}
}
System.out.println();
nst++;
row++;

}
}

}
the code is running properly on ide

This code runs fine for me and passes all the test cases .However i have copied the code here you can copy and paste your code from here .

this code still give the same error . but when i try on online IDE it runs properly . and the same thing is happening for every ques due to which i can not able to solve any problem i think it is a compiler error please review.
Error -
Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Manmohan.main(Manmohan.java:6)

Where is the code giving the error? On hackerblock or on your local system. And did you select the correct language . Because i tried the same code on hackerblock and it got correct answer with 100 points.

on hacker block my code is also running fine but in my java course the same error is coming whenever i want to take input from user it gives the same error for every code

See if you are sample running your code then you need to provide the custom input accordingly. Or else if this is not the problem then you are given less input then expected from the question. NoElementException is when the program demands for a input but there is not input provided or available.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.