gpt4 book ai didi

Java循环执行错误

转载 作者:行者123 更新时间:2023-12-02 05:49:29 26 4
gpt4 key购买 nike

这是我的代码:

import java.io.*;
import java.util.*;
class comp
{
int a,b,i,k,l;
comp()
{

Scanner s=new Scanner(System.in);
System.out.println("Enter the number");
a=s.nextInt();
b=s.nextInt();
divide(a,b);

}
public void display(int[] b)
{
for(i=0;i<b.length;i++)
System.out.println(b[i]);
}
public void divide(int e,int f)
{
int[] st=new int[20];
//System.out.println(e);
i=0;

if(e>0)
{
l=e%10;
e=e/10;
st[i]=l;
i++;

}
this.display(st);

//return st;

}



}
class km extends comp
{
public static void main(String args[])
{
km m=new km();



}
}

除法函数中的 if 循环仅执行一次。它应该精确执行到数字的位数。我只是想将整数转换为数组。

最佳答案

它不会重复,因为你有一个 if (e > 0)。

也许需要一段时间(e > 0)?

关于Java循环执行错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23701986/

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