当前位置:网站首页>刷题-洛谷-P1179 数字统计
刷题-洛谷-P1179 数字统计
2022-08-04 19:44:00 【宋向上_UP】
P1179 数字统计-C语言
1、题目
2、解题过程
结果:
代码:
//洛谷 P1179 数字统计
#include <stdio.h>
//#define MIN 1
//#define MAX 100000
int main() {
int l, r;//给定范围
int counter=0;//计数器
int i;
int temp,temp_2;
scanf("%d %d", &l, &r);
for (i = l; i <= r; i++) {
temp = i;
while (temp != 0) {
temp_2 = temp % 10;
if (temp_2 == 2) {
counter++;
}
temp = temp / 10;
}
}
printf("%d", counter);
return 0;
}
边栏推荐
猜你喜欢
随机推荐
2022年国内手机满意度榜单:华为稳坐国产品牌第一
程序员如何在职场上少走弯路?
二叉树的前序遍历
The difference between Client Side Cache and Server Side Cache
zynq records
[Awards for Essays] Autumn recruitment special training to create your exclusive product experience
手把手教你CSP系列之script-src
泰山OFFICE技术讲座:底纹、高亮、边框的关系
ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
Force KouTi (5), the longest text string back
致-.-- -..- -
Finished product upgrade program
如何推动乡村振兴的落地
SAP UI5 的初始化过程
Internship: changed the requirements
zynq 记录
Finger Vein Recognition-matlab
Spark提交参数说明和常见优化
MYSQL gets the table name and table comment of the database
成品升级程序