当前位置:网站首页>门牌制作 C语言
门牌制作 C语言
2022-07-02 22:09:00 【大菜彩】
门牌制作
小蓝要为一条街的住户制作门牌号。
这条街一共有 2020 位住户,门牌号从 1 到 2020 编号。
小蓝制作门牌的方法是先制作 0 到 9 这几个数字字符,最后根据需要将字符粘贴到门牌上,例如门牌 1017 需要依次粘贴字符 1、0、1、7,即需要 1 个字符 0,2 个字符 1,1 个字符 7。
请问要制作所有的 1 到 2020 号门牌,总共需要多少个字符 2?
代码:
#include<stdio.h>
int main()
{
int i,j,temp,count=0,a;
for(i=1;i<=2020;i++)
{
temp=i;
while(temp!=0)
{
a=temp%10; //取数字的最后一位
if(a==2)
count++;
temp=temp/10; //去掉数字的最后一位
}
}
printf("%d",count);
return 0;
} 边栏推荐
- Lambda expression: an article takes you through
- The motivation of AES Advanced Encryption Protocol
- 数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
- Niuke network: maximum submatrix
- PMP project integration management
- Go multithreaded data search
- Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
- Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
- Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年7月1日08:43:06
- Performance optimization - rigorous mode
猜你喜欢

Boot actuator - Prometheus use

Data analysis learning records -- complete a simple one-way ANOVA with Excel

MySQL查询附近的数据.并按距离进行排序.
![[Yangcheng cup 2020] easyphp](/img/12/da28f738e50e625b0a66a94af3703d.png)
[Yangcheng cup 2020] easyphp

中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!
![加油站[问题分析->问题转换->贪心]](/img/15/5313f900abedb46ce82d8ab81af1d7.png)
加油站[问题分析->问题转换->贪心]

P1007 single log bridge

从底层结构开始学习FPGA----Xilinx ROM IP的定制与测试

手写ORM(对象关系映射)增删改查

Generics and reflection, this is enough
随机推荐
2016. 增量元素之间的最大差值
地平线2022年4月最新方案介绍
[npuctf2020]ezlogin XPath injection
[leetcode] reverse the word III in the string [557]
Jerry's charge unplugged, unable to touch the boot [chapter]
pytorch训练CPU占用持续增长(bug)
Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
Golang interview finishing three resumes how to write
【硬件】标准阻值的由来
数据分析学习记录--用EXCEL完成简单的单因素方差分析
[NPUCTF2020]ezlogin xPATH注入
[favorite poems] OK, song
数据标注典型案例,景联文科技如何助力企业搭建数据方案
[羊城杯2020]easyphp
Data analysis learning records -- complete a simple one-way ANOVA with Excel
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements
首批 | 腾讯云完成国内首个云原生安全成熟度评估
容器化技术在嵌入式领域的应用
PMP project integration management
【喜欢的诗词】好了歌