当前位置:网站首页>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
}
边栏推荐
- Common protocols and download paths of NR
- 金融门户相关信息
- Fabric.js 圆形笔刷
- Here comes a new chapter in the series of data conversion when exporting with easyexcel!
- Creation and destruction of function stack frames
- Fabric.js IText 手动设置斜体
- Leetcode 18 problem [sum of four numbers] recursive solution
- Generate QR code
- 来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
- Fabric. JS activation input box
猜你喜欢
Nodejs (02) - built in module
2022-2-15 learning xiangniuke project - Section 8 check login status
Installation du tutoriel MySQL 8.0.22 par centos8
7.TCP的十一种状态集
Collectors. Groupingby sort
Fabric. JS iText sets the color and background color of the specified text
Gee: create a new feature and set corresponding attributes
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
el form 表单validate成功后没有执行逻辑
Software testing learning - day 4
随机推荐
brew install * 失败,解决方法
Installation du tutoriel MySQL 8.0.22 par centos8
摆正元素(带过渡动画)
简单封装 js并应用
中小型项目手撸过滤器实现认证与授权
Operator details
Résumé de la collection de plug - ins couramment utilisée dans les outils de développement idea
Gee data set: export the distribution and installed capacity of hydropower stations in the country to CSV table
Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
Fabric.js 自由绘制矩形
Paddlepaddle project source code
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
Gee series: Unit 2 explore datasets
Global and Chinese market of travel data recorder (VDR) 2022-2028: Research Report on technology, participants, trends, market size and share
Disable access to external entities in XML parsing
Online music player app
Fabric.js 精简JSON
Gee series: unit 10 creating a graphical user interface using Google Earth engine [GUI development]
Fabric. JS iText sets the color and background color of the specified text
【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘