//1~n整数中1出现的次数
//输入一个整数求1~n这个整数的十进制中1出现的次数
public class Sum1toN {
public static int sumOne(int num) {
int count = 0;
while (num>0) {
if (num % 10 == 1) {
count++;
}
num /= 10;
}
return count;
}
public static int Sum1toN(int num){
if(num<=0){
return -1;
}
int count=0;
for(int i=1;i<=num;i++){
count+=sumOne(i);
}
return count;
}
public static void main(String[] args){
;
System.out.println(Sum1toN(11));
}
}