当前位置:网站首页>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
}边栏推荐
- Fabric.js 基础笔刷
- Visual studio import
- Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
- "Original, excellent and vulgar" in operation and maintenance work
- Gee: analyze the change of spatial centroid of remote sensing image [centroid acquisition analysis]
- JVM class loading mechanism
- Online music player app
- Fabric.js IText 手动设置斜体
- Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
- Dark horse notes -- Set Series Collection
猜你喜欢

ThreadLocal memory leak

摆正元素(带过渡动画)

Black Horse Notes - - set Series Collection

Fabric. JS compact JSON

Fabric.js IText 手动设置斜体

Dark horse notes -- map set system

Youth training camp -- database operation project

在线音乐播放器app
![Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]](/img/7b/b9ef76cee8b32204331a9c3c21b5c2.jpg)
Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]

Gee series: Unit 2 explore datasets
随机推荐
Installation du tutoriel MySQL 8.0.22 par centos8
Youth training camp -- database operation project
"Original, excellent and vulgar" in operation and maintenance work
Fabric.js 自由绘制矩形
MySQL foundation --- query (learn MySQL foundation in 1 day)
Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
KMP idea and template code
黑马笔记---Set系列集合
Fabric. JS upload local image to canvas background
函数栈帧的创建和销毁
2022-2-15 learning xiangniuke project - Section 8 check login status
Gee series: Unit 4 data import and export in Google Earth engine
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
7.1模擬賽總結
Sliding window on the learning road
在线音乐播放器app
Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
Black Horse Notes - - set Series Collection
centos8安装mysql8.0.22教程