当前位置:网站首页>门牌制作 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;
}
边栏推荐
- 损失函数~
- Jerry's fast touch does not respond [chapter]
- World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
- STM32之ADC
- stop slave卡住--事务的事件没有复制完整
- boot actuator - prometheus使用
- 成功改变splunk 默认URL root path
- 移动端 1px 像素兼容性问题,实现1px 边框
- 创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
- mysql重置密码,忘记密码,重置root密码,重置mysql密码
猜你喜欢
泛型与反射,看这篇就够了
Lambda expression: an article takes you through
odoo13搭建医院HRP环境(详细步骤)
Gas station [problem analysis - > problem conversion - > greed]
LeetCode 968. Monitor binary tree
损失函数~
Looking at Ctrip's toughness and vision from the Q1 financial report in 2022
MySQL查询附近的数据.并按距离进行排序.
[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?
Array advanced improvement
随机推荐
Lambda expression: an article takes you through
1px pixel compatibility of mobile terminal, 1px border
解决Chrome浏览器和Edeg浏览器主页被篡改的方法
数据分析学习记录--用EXCEL完成简单的单因素方差分析
[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM
严守工期,确保质量,这家AI数据标注公司做到了!
PMP project integration management
Minimum spanning tree
Uniapp wechat login returns user name and Avatar
Chow-Liu Tree
[Yangcheng cup 2020] easyphp
[npuctf2020]ezlogin XPath injection
Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
Construction of Hisilicon 3559 universal platform: rotation operation on the captured YUV image
MySQL queries nearby data And sort by distance
编辑卡顿
【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线
go 4種單例模式
容器化技术在嵌入式领域的应用
antd组件upload上传xlsx文件,并读取文件内容