gpt4 book ai didi

java - JCreator找不到符号很简单

转载 作者:行者123 更新时间:2023-12-01 12:30:07 25 4
gpt4 key购买 nike

这显然不是完整的代码,但这是我遇到的问题。它应该写入 0 和我输入 ((x))) 中的任意数字之间的随机数。

for (int i=0; i<1; i=i+1){
int tal2 = 1 +
(int)(Math.random () * ((9)));
System.out.print("" + tal2);
}
for (int i=0; i<1; i=i+1){
int tal3 = 1 +
(int)(Math.random () * ((1)));
System.out.print("" + tal3);
}
if (tal3==1){
for (int i=0; i<1; i=1+1){
int tal4 = 1 +
(int)(Math.random () * ((2)));
System.out.print("" + tal4);
}
}
else if (tal3==0)
for (int i=0; i<1; i=i+1){
int tal4 = 1 +
(int)(Math.random () * ((9)));
System.out.print("" + tal4);

错误:找不到符号 如果(tal3==1){ ^错误:找不到符号 否则如果(tal3==0)

最佳答案

这是有效的答案。

class Hello    
{
public static void main(String[] args)
{
int tal2;
int tal3 =0;
int tal4 =0;
for (int i=0; i<1; i=i+1){
tal2 = 1 +(int)(Math.random () * ((9)));
System.out.print("" + tal2);
}
for (int i=0; i<1; i=i+1){
tal3 = 1 +(int)(Math.random () * ((1)));
System.out.print("\n" + tal3);
}
if (tal3==1){
for (int i=0; i<1; i=i+1){
tal4 = 1 +(int)(Math.random () * ((2)));
System.out.print("\n" + tal4);
}
}
else if (tal3==0)
for (int i=0; i<1; i=i+1){
tal4 = 1 +(int)(Math.random () * ((9)));
System.out.print("\n" + tal4);

}
}
}

关于java - JCreator找不到符号很简单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25993531/

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