编写程序数一下 1到 100 的所有整数中出现多少次数字9。

时间:2022-02-27 00:10:27
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<windows.h>
int main()
{
int i = 0 , count = 0;
for (i = 0; i <= 100; i++)
{
if (i / 10 == 9)
count++;
if (i % 10  == 9)
count++;
}

printf("从1到100里数字9的个数为:%d\n", count);
system("pause");
return 0;


}