判断数组元素是否从1到9


/**
 * 判断数组元素是否从1到9
 * @author tiger
 *
 */

public class kuangda {

 int flag = 0x3fe;
 int[] array = new int[]{2,1,3,9,5,6,7,8,4};
 
 private boolean isYesArray()
 {
  for (int i = 0; i < array.length; i++) {
   int abc = 0;
   abc = flag & (1 << array[i]);
   flag = flag - abc;
   if(abc == 0)return false;
  }
  return true;
 }
 
 /**
  * @param args
  */
 public static void main(String[] args) {
  System.out.println(new kuangda().isYesArray());
 }

}

posted on 2010-06-06 13:14  台哥编程课堂  阅读(245)  评论(0编辑  收藏  举报

导航