剑指offer之 整数中1出现的次数
public class Solution { public int NumberOf1Between1AndN_Solution(int n) { int count=0; for(int i=1;i<=n;i++){ count+=core(i); } return count; } private int core(int n){ int num=0; while(n!=0){ if(n%10==1){ num++; } n/=10; } return num; } }