首页 > 代码库 > HW6.23

HW6.23

技术分享

 

 1 public class Solution 2 { 3     public static void main(String[] args) 4     { 5         boolean[] box = new boolean[101]; 6  7         for(int i = 1; i <= 100; i++) 8         { 9             for(int j = i; j <= 100; j += i)10                 changeBox(box, j);11         }12 13         for(int i = 1; i <= 100; i++)14             System.out.printf("%d\t%b\n", i, box[i]);15     }16 17     public static void changeBox(boolean[] array, int flag)18     {19         if(array[flag] == true)20             array[flag] = false;21         else22             array[flag] = true;23     }24 }

 

HW6.23