当前位置:网站首页>Binary and decimal system of C language
Binary and decimal system of C language
2022-07-02 09:41:00 【FF small confused acridine~】
Binary is a number system widely used in computing technology . Binary data is used 0 and 1 A number represented by two numbers . But in real life , People use the decimal system , It may be related to the fact that humans have ten fingers . So how to realize the conversion between binary and decimal ?
problem :
Input 4 Contains only 0 and 1 The integer of ( Binary number ), Print the decimal equivalent .
Programming requirements :
1、 According to the requirements of the topic, realize the hexadecimal conversion , With the help of printf Function output result ;
2、 Use scanf Function to input data ;
3、 Please output strictly according to the output effect ;( Affect the performance evaluation )
4、 When submitting the code of the task, it is necessary to ensure that it conforms to the industry code specification , You need to indent and wrap as necessary .( Affect the performance evaluation )
Running effect :
Please enter only 4 The binary number of bits :1101
The corresponding decimal number is :13
Please press any key to continue . . .
#include <stdio.h>
int main(void)
{
int number, result, a, b, c, d;
printf(" Please enter only 4 The binary number of bits :");
scanf("%d", &number);
a = number / 1000 ;
b = number / 100 % 10;
c = number / 10 % 10;
d = number % 10;
printf(" The corresponding decimal number is :%d\n", a * 8 + b * 4 + c * 2 + d);
return 0;
}
边栏推荐
- Hystrix implements request consolidation
- Creation and jump of activity
- Read 30 minutes before going to bed every day_ day4_ Files
- Pool de connexion redis personnalisé
- Timed thread pool implements request merging
- Double non undergraduate students enter the factory, while I am still quietly climbing trees at the bottom (Part 1)
- BugkuCTF-web16(备份是个好习惯)
- 分布式锁的这三种实现方式,如何在效率和正确性之间选择?
- 大学生四六级作文模板(自创版,成功跨过六级)
- 2837xd Code Generation - stateflow (4)
猜你喜欢
YOLO物体识别,生成数据用到的工具
Insight into cloud native | microservices and microservice architecture
2837xd Code Generation - stateflow (4)
View the port of the application published by was
企业级SaaS CRM实现
In depth analysis of how the JVM executes Hello World
Idempotent design of Internet API interface
自定义Redis连接池
上班第一天的报错(AWVS卸载不彻底)
图像识别-数据标注
随机推荐
分享一篇博客(水一篇博客)
tinyxml2 读取和修改文件
一次聊天勾起的回忆
Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
Typora安装包分享
Thinkphp5 how to determine whether a table exists
How to install PHP in CentOS
Supplier selection and prequalification of Oracle project management system
kinect dk 获取CV::Mat格式的彩色RGB图像(openpose中使用)
cmake的命令-官方文档
告别996,IDEA中必装插件有哪些?
C语言之分草莓
分布式锁的这三种实现方式,如何在效率和正确性之间选择?
In depth analysis of how the JVM executes Hello World
Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
Long summary (code with comments) number structure (C language) -- Chapter 4, string (Part 1)
Discussion on improving development quality and reducing test bug rate
Solutions to Chinese garbled code in CMD window
攻防世界-Web进阶区-unserialize3
每天睡觉前30分钟阅读_day3_Files