public class Solution { public int NumberOf1Between1AndN_Solution(int n) { int wei = 1 ;//个十百 int count = 0 ; while(n / wei != 0) { int high = n/wei/10 ; int cur = n/wei%10 ; int low = n%wei; if(cur == 0) { count += high * wei ; } else if(cur == 1) { count += ((low + 1) + high*wei) ; } else { count += (high + 1) * wei ; } wei *= 10 ; } return count ; } }