当前位置:网站首页>门牌制作 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;
}
边栏推荐
- The kth largest element in the [leetcode] array [215]
- PMP project integration management
- How does Jerry test the wrong touch rate of keys [chapter]
- 情感对话识别与生成简述
- 手写ORM(对象关系映射)增删改查
- psnr,ssim,rmse三个指标的定量分析
- [Luogu p1541] tortoise chess [DP]
- Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
- 【板栗糖GIS】arcscene—如何做出有高度的高程图
- 【板栗糖GIS】arcmap—为什么使用自定义捕捉的时候,经典捕捉的勾要去掉呢?
猜你喜欢
Chow-Liu Tree
[羊城杯2020]easyphp
Addition, deletion, modification and query of handwritten ORM (object relationship mapping)
數據分析學習記錄--用EXCEL完成簡單的單因素方差分析
P1007 独木桥
从底层结构开始学习FPGA----Xilinx ROM IP的定制与测试
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements
容器化技术在嵌入式领域的应用
STM32之ADC
Go language sqlx library operation SQLite3 database addition, deletion, modification and query
随机推荐
分布式监控系统zabbix
Jatpack------LiveData
Niuke network: maximum submatrix
Chow-Liu Tree
P7072 [CSP-J2020] 直播获奖
stop slave卡住--事务的事件没有复制完整
Easyclick, EC Quanlang network verification source code
Learning Websites commonly used by circuit designers
Splunk audit setting
AES高級加密協議的動機闡述
Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
P7072 [csp-j2020] live broadcast Award
Mask R-CNN
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
海思3559万能平台搭建:在截获的YUV图像上画框
Odoo13 build a hospital HRP environment (detailed steps)
Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?
Go four singleton modes
位的高阶运算