标签:off 1出现的次数 java += while public for tween 剑指offer
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;
}
}
标签:off 1出现的次数 java += while public for tween 剑指offer
原文地址:http://www.cnblogs.com/toov5/p/7662370.html