数一下1到100w之间含有9的数字

include<stdio.h>
include<stdlib.h>
int main()
{
 int i = 0;
 int j = 0;
 int d = 0;
 int count = 0;
 for (i = 1; i <= 100; i++)
 {
  j = i;
  d = j % 10;
  if (d == 9)
  {
   count++;
  }
 } 
 printf("count = %d\n", count);
 system("pause");                                                                                                                                      
 return 0;
}

猜你喜欢

转载自blog.csdn.net/HuiDiExAg/article/details/89390646