/*题目:通过编程实现,统计1~n有多少个9 提示:n通过参数传入*/
#include <stdio.h>
int main()
{
int n;
printf("璇疯緭鍏鐨勫€硷細\n");
scanf("%d",&n);
int i = 1,count = 0,temp;
while(i<=n)
{
temp = i;
while(temp!=0)
{
if(temp%10 == 9)
{
count++;
}
temp = temp/10;
}
i++;
}
printf("the result is:%d",count);
return 0;
}
#include <stdio.h>
int main()
{
int n;
printf("璇疯緭鍏鐨勫€硷細\n");
scanf("%d",&n);
int i = 1,count = 0,temp;
while(i<=n)
{
temp = i;
while(temp!=0)
{
if(temp%10 == 9)
{
count++;
}
temp = temp/10;
}
i++;
}
printf("the result is:%d",count);
return 0;
}