题解 | #整数中1出现的次数(从1到n整数中1出现的次数)#
整数中1出现的次数(从1到n整数中1出现的次数)
http://www.nowcoder.com/practice/bd7f978302044eee894445e244c7eee6
public int NumberOf1Between1AndN_Solution(int n) {
//暴力破解
int number = 0;
for(int i = 1 ;i<=n ;i++){
int temp = i;
while(temp > 0){
if(temp % 10 == 1){
number ++;
}
temp /= 10;
}
}
return number;
}
}