#include<stdio.h> #include<stdlib.h> void NineNumber() { int num = 1; int count = 0; int unit = 0; int ten = 0; int hundred = 0; for (; num <= 100; num++) { hundred = num / 100; ten = (num - hundred * 100) / 10; unit = (num - hundred * 100 - ten * 10) / 1; if (hundred == 9) { count++; } if (ten == 9) { count++; } if (unit == 9) { count++; } } printf("%d\n", count); } int main() { NineNumber(); system("pause"); return 0; }
C语言:编写程序数一下 1到 100 的所有整数中出现多少次数字 9
原创文章标签 C语言 1到 100 的所有整数中出现多少次数 计算整数出现次数 判断个位、十位、百位 文章分类 C/C++ 后端开发
-
1.顺序表的实现——C语言
顺序表各种操作的代码实现
顺序表 冒泡排序 算法 随机数