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

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>
int main()
{
 int i;
 int count=0;
 for (i = 1; i <= 100; i++) 
   {  
      if (i % 10 == 9)
        {
          count++;
        }
      if (i / 10 == 9)
        {
          count++;
        }
   } 
         printf("结果为:%d", count);
         printf("\n");
         system("pause");
         return 0;
}

猜你喜欢

转载自blog.csdn.net/LXL7868/article/details/88639392