首页 > 其他 > 详细

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

时间:2015-11-06 07:14:58      阅读:215      评论:0      收藏:0      [点我收藏+]

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

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <stdlib.h>

int main()

{

int i = 0;

int count = 0;

for (i = 0; i <= 100; i++)

{

if (i % 10 == 9)

{

count++;

}

if (i / 10 == 9)

{

count++;

}

}

printf("count=%d\n", count);

system("pause");

return 0;

}


本文出自 “Stand out or Get out” 博客,转载请与作者联系!

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

原文:http://jiazhenzhen.blog.51cto.com/10781724/1710202

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!