2016-08-23 3 views
-4

//タイトル:1,2,3,4人の数字は、3桁の数字を繰り返さずにお互いの数を構成できますか?何人ですか?なぜ私はこのプロセスを実行できないのですか?私は3つを使用しますが、間違いを報告します

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); 
      } 
    } 
} 
+1

エラーについての質問は、*完全な*エラーを完全かつ未編集で含めてください。あなたの質問を編集して、コンパイラやランタイムがあなたに言っていることを含めてください。 –

+3

'shi'は2番目のforループのスコープ内で宣言されていますが、3番目のforの宣言ではアクセスできません。 –

+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ループの外側にshiを宣言してください。この問題に遭遇するべきではありません。

+0

はい、私はあなたを知っています。私は反対します。ありがとうございました。 –

関連する問題