0
点赞
收藏
分享

微信扫一扫

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

腊梅5朵 2022-12-30 阅读 61

#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

#include<string.h>

#include<math.h>

#include <stdlib.h>

#include <time.h>

int main()

{

int ret = 0;

int count = 0;

for(ret = 1; ret <= 100; ret++)

{

  if(ret % 10 == 9)

  {

   printf("%d\n",ret);

   count++;

  }

 if(ret / 10 == 9)

 {  

  printf("%d\n",ret);

  count++;

 }



}

 

printf("\n9的个数count=%d\n",count);

   system("pause");

return 0;

}

举报

相关推荐

0 条评论