当前位置:网站首页>Zzuli:1067 faulty odometer
Zzuli:1067 faulty odometer
2022-07-02 05:30:00 【Don't explode】
Title Description
A car has an odometer , The odometer can display an integer , For the number of kilometers the car has traveled . However, there is something wrong with this odometer : It always comes from 3 Change to 5, And skip numbers 4, All bits of the odometer ( bits 、 ten 、 One hundred, etc ) The numbers on the are all like this . for example , If the odometer shows 339, The car passed by 1 Km later , The odometer shows 350.
Input
Enter an integer num, Indicates the value displayed by the odometer ,1 < num < 1000, And must not contain integers 4.
Output
Output an integer , Is the actual mileage of the car . for example , If the odometer shows 55, Then the actual kilometers traveled The number is 40.
The sample input Copy
106
Sample output Copy
86
Tips
Method 1: This is the case when the data of this question is small , A loop can be used to simulate . Use one 1~num The cycle of , During the cycle , Count with another loop variable , Statistics do not contain figures 4 Number of integers .
Method 2: This question is slightly modified , Can be converted to a 9 Base to zero 10 The question of system , This method is more general .
#include <stdio.h>
int main()
{
int n,i;// Define loop variables i Sum represents number n
scanf("%d",&n);// Enter the display number of the table n
int x=0; // Define actual mileage x
for(i=1;i<=n;i++)
{
if(i%10==4)continue;// If the one digit number is 4, Skip this time
if((i/10%10)==4)continue;// If the ten digit number is 4, Skip this time
if((i/100)%10==4)continue;// If the hundred digit number is 4, Skip this time
x++;// If you don't jump out in front , Then the actual mileage plus 1
}
printf("%d",x);// Output actual mileage
return 0;// Program exit normally
}
边栏推荐
- idea开发工具常用的插件合集汇总
- Usage record of vector
- Fabric. JS basic brush
- 视差特效的原理和实现方法
- Online music player app
- idea開發工具常用的插件合集匯總
- Nodejs (02) - built in module
- el form 表单validate成功后没有执行逻辑
- 460. LFU 缓存 双向链表
- Global and Chinese market of insulin pens 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Straighten elements (with transition animation)
centos8安装mysql8.0.22教程
Fabric.js 居中元素
Gee series: Unit 4 data import and export in Google Earth engine
Fabric.js 将本地图像上传到画布背景
[technical notes-08]
Win10 copy files, save files... All need administrator permission, solution
Fabric.js 右键菜单
Dark horse notes -- map set system
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
随机推荐
Global and Chinese markets of semiconductor laser therapeutics 2022-2028: Research Report on technology, participants, trends, market size and share
Get the details of the next largest number
Leetcode18题 【四数之和】递归解法
Principle and implementation of parallax effect
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
Fabric.js 激活输入框
Fabric. JS centered element
生成二维码
460. LFU cache bidirectional linked list
延时队列两种实现方式
Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
Gee series: Unit 1 Introduction to Google Earth engine
Gee data set: export the distribution and installed capacity of hydropower stations in the country to CSV table
Gee series: unit 8 time series analysis in Google Earth engine [time series]
7. Eleven state sets of TCP
Thread pool overview
460. LFU 缓存 双向链表
2022-2-15 learning xiangniuke project - Section 8 check login status
来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
RNN recurrent neural network