当前位置:网站首页>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;
}
边栏推荐
- idea查看字节码配置
- Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
- QT signal slot summary -connect function incorrect usage
- Who is better for Beijing software development? How to find someone to develop system software
- 图像识别-数据标注
- 保存视频 opencv::VideoWriter
- 告别996,IDEA中必装插件有哪些?
- Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
- VIM操作命令大全
- Creation and jump of activity
猜你喜欢

web安全与防御

在SQL注入中,为什么union联合查询,id必须等于0

PI control of three-phase grid connected inverter - off grid mode

并网逆变器PI控制(并网模式)

Image recognition - Data Cleaning

Matplotlib swordsman - a stylist who can draw without tools and code

Chrome browser plug-in fatkun installation and introduction

Solutions to Chinese garbled code in CMD window

hystrix 实现请求合并

Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
随机推荐
Share a blog (water blog)
Chrome video download Plug-in – video downloader for Chrome
Knowledge points are very detailed (code is annotated) number structure (C language) -- Chapter 3, stack and queue
2837xd 代码生成——补充(3)
三相并网逆变器PI控制——离网模式
VIM操作命令大全
一次聊天勾起的回忆
C语言之二进制与十进制
Probability is not yet. Look at statistical learning methods -- Chapter 4, naive Bayesian method
Knife4j 2.X版本文件上传无选择文件控件问题解决
Enterprise level SaaS CRM implementation
QT信号槽总结-connect函数错误用法
2837xd code generation - stateflow (4)
C语言之数据插入
C语言之判断直角三角形
FragmentTabHost实现房贷计算器界面
vs+qt 设置应用程序图标
idea查看字节码配置
Don't look for it. All the necessary plug-ins for Chrome browser are here
Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)