1.个位是9
模10余9
2.十位是9
除以10得整数部分为9
3.十位个位都是9
test.c
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int i = 0;
int count = 0;
for (i = 1; i <= 100; i++)
{
if (i % 10 == 9)
{
count++;
}
if (i / 10 == 9)
{
count++;
}
}
printf("count=%d\n", count);
system("pause");
return 0;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6456e6d0b8178a61f5e67aee96e35ac2.png)