The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's in 1, 10, 11, and 12. Input Specification: Each inp
个位ch个数 + 十位ch个数 * 10 + 百位ch个数 * 100:同时如果某一位刚好等于ch,还需要减去多算的一部分值. #include <stdio.h> //整数1到n,字符ch出现的次数:如1到12,1出现5次 int count1s (int n, char ch){ int i = ch - '0'; int count = 0; int j = 1; int m = n; int t = 0; int k = 1; if (i == 0) i = 10; //循环比较最后一