//标题:1,2,3,4数字,相互之间没有重复的三位数数字可以组成?有多少?
public class Eleven {
public static void main(String[] args) {
// Definition of one hundred , ten , a bit
// The first one hundred first statistics
for (int i = 1; i < 5; i++) {
// This bit is a one hundred
int bai = i;
for (int j = 1; j < 5 && (i != j); j++) {
int shi = j;
}
//Question1:Icannot understand it,Why it tell me mistake?a<5 &&(a !=bai &&(a !=shi)
for (int a = 1; a < 5 && (a != bai && (a != shi)); a++) {
int ge = a;
}
//Define a three-digit number , his output
int Threefingue = bai * 100 + shi * 10 + ge;
System.out.print(Threefingue);
}
}
}
答案 0 :(得分:0)
问题(我想,既然你没有提到你得到的错误,就在这些内容中:
//Define the ten
int shi=j;
}
//Question1:Icannot understand it,Why it tell me mistake?a<5 &&(a !=bai &&(a !=shi)
for(int a =1;a<5 &&(a !=bai &&(a !=shi));a++)
{
//Define the bit
int ge=a;
}
实际上,在第一个for
循环中,您声明int shi
,因此您只能在第一个for循环中使用它。但是,在第二个for
循环的条件下,您也会使用它。你不应该这样做。要解决这个问题,请在第一个for
循环之外声明shi,并且不应该遇到这个问题。