#include<stdio.h> int main() { int page_num; printf("请输入你要计算的页码:"); scanf("%d", &page_num); int i, temp; int count[10] = {0}; for(i = 1; i <= page_num; i++) { temp = i; while(temp) { count[temp%10]++; temp/=10; } } for(i = 0; i < 10; i++) { printf("数字%d出现的次数为:%d\n", i, count[i]); } return 0; }
原文:http://www.cnblogs.com/Ridgway/p/6971451.html