java我在codechef中遇到一个NZEC错误
在codechef中提交此代码时出现NZEC错误
import java.util.Scanner;
class Codechef
{
public static void main(String[] args)throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int test=sc.nextInt();
for(int i=1; i<=test; i++)
{
int n=sc.nextInt();
Integer num=n;
int length=(int)Math.pow(10, num.toString().length()-1);
while(length>0)
{
System.out.println(num);
num%=length;
length/=10;
}
}
}
}
# 1 楼答案
如果您有一个输入文件,其中要跟随的整数数大于实际整数数,则nextInt会抛出一个NoTouchElementException
使用
hasNextInt
测试输入中另一个数字的可用性