当前位置:网站首页>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+边栏推荐
- ncs成都新电面试经验
- About using CDN based on Kangle and EP panel
- Greenplum6.x搭建_环境配置
- 下载和安装orcale database11.2.0.4
- A bug using module project in idea
- Leetcode 1984. Minimum difference in student scores
- 国标GB28181协议视频平台EasyGBS新增拉流超时配置
- [Yugong series] February 2022 U3D full stack class 006 unity toolbar
- 【踩坑】nacos注册一直连接localhost:8848,no available server
- [Yu Yue education] C language programming reference of Zhongbei College of Nanjing Normal University
猜你喜欢

数据分片介绍

归并排序和非比较排序

Novice entry SCM must understand those things
![Upload an e-office V9 arbitrary file [vulnerability recurrence practice]](/img/e7/278193cbc2a2f562270f99634225bc.jpg)
Upload an e-office V9 arbitrary file [vulnerability recurrence practice]
![FPGA knowledge accumulation [6]](/img/db/c3721c3e842ddf4c1088a3f54e9f2a.jpg)
FPGA knowledge accumulation [6]

Splunk query CSV lookup table data dynamic query

下载和安装orcale database11.2.0.4

Opencv learning note 4 - expansion / corrosion / open operation / close operation

How to integrate app linking services in harmonyos applications

Data type - integer (C language)
随机推荐
The field value in Splunk subquery fuzzy matching CSV is*
AVL平衡二叉搜索树
A bug using module project in idea
联想混合云Lenovo xCloud:4大产品线+IT服务门户
MySQL partition explanation and operation statement
Routing information protocol rip
Download and install orcale database11.2.0.4
ES6_ Arrow function
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"
[step on the pit] Nacos registration has been connected to localhost:8848, no available server
Tips for using jeditabletable
2-3查找樹
测试踩坑 - 当已有接口(或数据库表中)新增字段时,都需要注意哪些测试点?
How to realize the high temperature alarm of the machine room in the moving ring monitoring system
Sign and authenticate API interface or H5 interface
Category of IP address
2-3查找树
数据分析方法论与前人经验总结2【笔记干货】
Greenplum6.x监控软件搭建
Virtual address space