Why I cannot run this process?I use three for,but it report mistakeAsk Question


// Title: 1,2,3,4 figures , the number of each other with no repeat of the three-digit numbers can be composed ? How many are ?

 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;



The problem (I suppose since you don't mention the error you get, lies within these lines:

//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;

Indeed, in the first for loop you declare int shi so you can only use it in this first for loop. However you do use it as well in the condition of your second for loop. You should not do that. To solve this, declare shi outside of the first for loop and you should not run into this problem.

标签: math
© 2014 TuiCode, Inc.