当前位置:网站首页>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開發工具常用的插件合集匯總
- Draw a wave chart_ Digital IC
- Usage record of vector
- LeetCode 241. Design priorities for operational expressions (divide and conquer / mnemonic recursion / dynamic programming)
- H5 jump applet
- 7.1模擬賽總結
- 2022-2-14 learning xiangniuke project - Section 6 displays login information
- Gee series: unit 7 remote sensing image classification using GEE [random forest classification]
- LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)
- Appnuim environment configuration and basic knowledge
猜你喜欢

"Original, excellent and vulgar" in operation and maintenance work

Basic use of form

6. Network - Foundation

Operator details

Importation de studio visuel

【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘

Disable access to external entities in XML parsing

Gee: remote sensing image composite and mosaic

brew install * 失败,解决方法

Fabric.js 居中元素
随机推荐
黑马笔记---Map集合体系
Fabric.js 渐变
2022-2-14 learning xiangniuke project - Section 6 displays login information
460. LFU cache bidirectional linked list
Appnuim environment configuration and basic knowledge
Usage record of vector
Thread pool overview
Fabric. JS iText set italics manually
Global and Chinese market of hydrocyclone desander 2022-2028: Research Report on technology, participants, trends, market size and share
Software testing learning - day 4
Fabric. JS background is not affected by viewport transformation
Online English teaching app open source platform (customized)
Gee: explore the characteristics of precipitation change in the Yellow River Basin in the past 10 years [pixel by pixel analysis]
Gee: remote sensing image composite and mosaic
中小型项目手撸过滤器实现认证与授权
KMP idea and template code
延时队列两种实现方式
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
Visual studio import
生成二维码