当前位置:网站首页>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+
边栏推荐
- Appeler l'interface du moteur de création du service multimédia de jeu Huawei renvoie le Code d'erreur 1002, le message d'erreur: les paramètres sont l'erreur
- 数据中台落地实施之法
- leetcode134. gas station
- 南京商品房买卖启用电子合同,君子签助力房屋交易在线网签备案
- 归并排序和非比较排序
- Greenplum6.x搭建_环境配置
- 数据分析方法论与前人经验总结2【笔记干货】
- Qt Charts使用(重写QChartView,实现一些自定义功能)
- let const
- 基本数据类型和string类型互相转化
猜你喜欢
Greenplum6.x-版本变化记录-常用手册
Exercise arrangement 2.10, 11
Input and output of floating point data (C language)
Greenplum6.x常用语句
JS operation
Splunk query CSV lookup table data dynamic query
数据分片介绍
let const
Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot
数据分析方法论与前人经验总结2【笔记干货】
随机推荐
[step on the pit] Nacos registration has been connected to localhost:8848, no available server
leetcode134. gas station
let const
Compilation and linking of programs
详解华为应用市场2022年逐步减少32位包体上架应用和策略
FPGA knowledge accumulation [6]
求有符号数的原码、反码和补码【C语言】
Greenplum6.x搭建_环境配置
Interpolation lookup (two methods)
数据分析方法论与前人经验总结2【笔记干货】
Tips for using jeditabletable
Shell script for changing the current folder and the file date under the folder
SSM 整合
指针进阶,字符串函数
[Chongqing Guangdong education] organic electronics (Bilingual) reference materials of Nanjing University of Posts and Telecommunications
归并排序和非比较排序
Golang 编译约束/条件编译 ( // +build <tags> )
[南京大学]-[软件分析]课程学习笔记(一)-introduction
What are the advantages of commas in conditional statements- What is the advantage of commas in a conditional statement?
[Chongqing Guangdong education] audio visual language reference materials of Xinyang Normal University