#include <stdio.h>
#include <windows.h>
int main()
{
int a=total_nice();
printf(“1到100中9的个数为%d\n”, a);
system(“pause”);
return 0;
}
int total_nice()
{
int total = 0;
int i = 0;
for (; i < 100; i++)
{
if (i % 10 == 9)// 判定个位上的九
{
total++;
}
if (i / 10 == 9)//判定十位上的九
total++;
}
return total;
}
C语言判断1到100中有多少个9
最新推荐文章于 2022-02-08 15:33:02 发布