当前位置:网站首页>Find the original code, inverse code and complement of signed numbers [C language]
Find the original code, inverse code and complement of signed numbers [C language]
2022-07-07 08:45:00 【Study silently every day】
/* Signed binary number inverse and complement */
#include<stdio.h>
int main()
{
int n,d,i,j;
printf(" Please enter the number of digits of the signed binary number :");
scanf("%d",&n);
int a[n],b[n],c[n];
printf(" Please enter the binary number :");
for(int i=0;i<n;i++) // Enter binary number
{
scanf("%d",&d);
a[i]=d;
}
if(a[0]==0)
{
printf(" The original code of the binary number = Inverse code = Complement code :"); // The original code of a positive number , Inverse and complement are the same
for(int i=0;i<n;i++) //
{
printf("%d",a[i]);
}
}
else if(a[0]==1)
{
printf(" The original code of the binary number :"); // Print the original code of negative numbers
for(i=0;i<n;i++) //
{
printf("%d",a[i]);
}printf("\n");
for(i=1;i<n;i++) // Judge whether the sign bit of the number is 1, Others are 0
{
if(a[i]!=0)
break;
}
if(i==n){ // If it is , Only original code and inverse code
printf(" This number has only original code and complement , There is no inverse code \n");
printf(" The complement of this number is :");
for(j=0;j<n;j+边栏推荐
- 详解华为应用市场2022年逐步减少32位包体上架应用和策略
- Greenplum6.x重新初始化
- idea里使用module项目的一个bug
- Opencv converts 16 bit image data to 8 bits and 8 to 16
- In go language, function is a type
- Data type - floating point (C language)
- Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年7月6日-新手快速上手-可无缝升级tp6版本
- About using CDN based on Kangle and EP panel
- Interpolation lookup (two methods)
- 测试踩坑 - 当已有接口(或数据库表中)新增字段时,都需要注意哪些测试点?
猜你喜欢

详解华为应用市场2022年逐步减少32位包体上架应用和策略

【MySQL】数据库进阶之触发器内容详解

2-3查找树

国标GB28181协议视频平台EasyGBS新增拉流超时配置

Arm GIC (IV) GIC V3 register class analysis notes.

打通法律服务群众“最后一公里”,方正璞华劳动人事法律自助咨询服务平台频获“点赞”

Rapid integration of authentication services - harmonyos platform

如何在快应用中实现滑动操作组件
![[step on the pit] Nacos registration has been connected to localhost:8848, no available server](/img/ee/ab4d62745929acec2f5ba57155b3fa.png)
[step on the pit] Nacos registration has been connected to localhost:8848, no available server

A method for quickly viewing pod logs under frequent tests (grep awk xargs kuberctl)
随机推荐
Several ways of lambda used in functions in kotlin (higher-order functions)
更改当前文件夹及文件夹下文件日期shell脚本
如何在图片的目标中添加目标的mask
21 general principles of wiring in circuit board design_ Provided by Chengdu circuit board design
指针进阶,字符串函数
How to integrate app linking services in harmonyos applications
[Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
JEditableTable的使用技巧
[hard core science popularization] working principle of dynamic loop monitoring system
Image segmentation in opencv
Opencv learning notes II - basic image operations
National SMS center number inquiry
联想混合云Lenovo xCloud:4大产品线+IT服务门户
2-3查找树
[Nanjing University] - [software analysis] course learning notes (I) -introduction
23 Chengdu instrument customization undertaking_ Discussion on automatic wiring method of PCB in Protel DXP
如何在快应用中实现滑动操作组件
[南京大学]-[软件分析]课程学习笔记(一)-introduction
Opencv learning note 4 - expansion / corrosion / open operation / close operation
AVL balanced binary search tree