#include <stdio.h> int main() { int n=1; int count=0; while(n<=100) { if(n%10==9) { count++; /*个位上含数字9的*/ } if(n-n%10==90) { count++; /*十位上含数字9的个数*/ } n++; } printf("9出现的次数:%d\n",count); return 0; }
编写程序数一下 1到 100 的所有整数中出现多少次数字 9
原文:http://10740329.blog.51cto.com/10730329/1700632