当前位置:网站首页>门牌制作 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;
}
边栏推荐
- mysql重置密码,忘记密码,重置root密码,重置mysql密码
- Golang interview finishing three resumes how to write
- Learning records of data analysis (II) -- simple use of response surface method and design expert
- Pytorch training CPU usage continues to grow (Bug)
- Easyclick, EC Quanlang network verification source code
- Jatpack------LiveData
- Go condition variable
- odoo13搭建医院HRP环境(详细步骤)
- 分布式监控系统zabbix
- QT qsplitter splitter
猜你喜欢
PMP project integration management
[Solved] Splunk: Cannot get username when all users are selected“
分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少
WebRTC音视频采集和播放示例及MediaStream媒体流解析
数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
P1007 single log bridge
Hanging mirror security won four global infosec awards on rsac2022
Splunk audit 的设定
LeetCode 968. Monitor binary tree
P7072 [CSP-J2020] 直播获奖
随机推荐
Lambda expression: an article takes you through
WebRTC音视频采集和播放示例及MediaStream媒体流解析
Go four singleton modes
Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?
Pytorch training CPU usage continues to grow (Bug)
Webrtc audio and video capture and playback examples and mediastream media stream analysis
The motivation of AES Advanced Encryption Protocol
高并发介绍及应对
【喜欢的诗词】好了歌
Kubernetes uses the host name to allocate the pod on the specified node
电路设计者常用的学习网站
Looking at Ctrip's toughness and vision from the Q1 financial report in 2022
Distributed monitoring system ZABBIX
LeetCode 968. Monitor binary tree
Splunk audit 的设定
Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
go 条件变量
Methods to solve the tampering of Chrome browser and edeg browser homepage
Higher order operation of bits