gpt4 book ai didi

java - UVA Online Judge 正在返回我找不到的运行时错误

转载 作者:行者123 更新时间:2023-12-05 01:47:40 26 4
gpt4 key购买 nike

<分区>

我一直在尝试关于 UVA 的第 100 题:

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=36

但是,它一直告诉我我的代码有运行时错误,我无法在自己的终端重现这些错误。它在我的控制台上工作得很好。我已经尝试了其他人的解决方案,但仍然无法正常工作。我什至删除了指定的所有公共(public)方法。

还有哪些其他可能的原因导致我遇到此问题?

这是我的代码:

import java.util.*;

class Main {
public static void main(String args[]){

int i =0;
int j=0;

Scanner input = new Scanner(System.in);

i = input.nextInt();
j = input.nextInt();

while((i!=0)&&(j!=0))
{
int tempMax = 0;
for(int k =i; k <= j; k++){
if (tempMax<AlgStep(1,k))
tempMax=AlgStep(1,k);
}

System.out.println(i + " " + j + " " + tempMax);

i = input.nextInt();
j = input.nextInt();

}


}

static boolean isEven(int n){
if(n%2==0)
return true;
else
return false;
}

static boolean isOne(int n){
if(n==1)
return true;
else
return false;
}

static int AlgStep(int count, int n){

int newCount;
int m;

if(isOne(n))
return count;
if(isEven(n)){
m = n/2;
newCount = count+1;
}
else{
m = (3*n)+1;
newCount = count+1;
}
return AlgStep(newCount, m);
}

}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com