hasOne

public boolean hasOne(int n) {
  int lastdigit=0;
  while( n >0 ){
    
    lastdigit=(n % 10);
    if(lastdigit==1) return true;
    n=n/10;
    
  }
  return false;
}

http://codingbat.com/prob/p191212

 

posted @ 2017-02-15 21:05  友哥  阅读(174)  评论(0编辑  收藏  举报