当前位置:网站首页>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+
边栏推荐
- [Chongqing Guangdong education] accounting reference materials of Nanjing University of Information Engineering
- Calling the creation engine interface of Huawei game multimedia service returns error code 1002, error message: the params is error
- What is the method of manual wiring in PCB design in 22protel DXP_ Chengdu electromechanical Development Undertaking
- Obsidan之数学公式的输入
- 字符串操作
- Basic data types and string types are converted to each other
- 国标GB28181协议视频平台EasyGBS新增拉流超时配置
- 2 - 3 arbre de recherche
- GOLand idea intellij 无法输入汉字
- A single game with goods increased by 100000, and the rural anchor sold men's clothes on top of the list?
猜你喜欢
How to realize the high temperature alarm of the machine room in the moving ring monitoring system
opencv之图像分割
Opencv learning notes 1 -- several methods of reading images
let const
iptables 之 state模块(ftp服务练习)
下载和安装orcale database11.2.0.4
leetcode135. Distribute candy
A bug using module project in idea
Go语言中,函数是一种类型
Three series of BOM elements
随机推荐
Input and output of floating point data (C language)
[kuangbin] topic 15 digit DP
Implementation method of data platform landing
A method for quickly viewing pod logs under frequent tests (grep awk xargs kuberctl)
JS operation
PLSQL的安装和配置
You should use Google related products with caution
FPGA knowledge accumulation [6]
[Yu Yue education] C language programming reference of Zhongbei College of Nanjing Normal University
一种适用于应用频繁测试下快速查看Pod的日志的方法(grep awk xargs kuberctl)
如何在快应用中实现滑动操作组件
[paper reading] icml2020: can autonomous vehicles identify, recover from, and adapt to distribution shifts?
快速集成认证服务-HarmonyOS平台
Input of mathematical formula of obsidan
[kuangbin]专题十五 数位DP
调用华为游戏多媒体服务的创建引擎接口返回错误码1002,错误信息:the params is error
Gson converts the entity class to JSON times declare multiple JSON fields named
Through the "last mile" of legal services for the masses, fangzheng Puhua labor and personnel law self-service consulting service platform has been frequently "praised"
Opencv converts 16 bit image data to 8 bits and 8 to 16
为什么要选择云原生数据库