这显然不是整个代码,但这是我遇到的问题。它应该写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);
错误:找不到符号 if(tal3 == 1){ ^ 错误:找不到符号 否则如果(tal3 == 0)
答案 0 :(得分:1)
这是工作答案。
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);
}
}
}