如何在输入一个使用c语言具有相同数量1的二进制数的数字后找到第一个数字 [英] how to Find the first number after input a number which has the same number of 1 both of their Binary Number using c language

查看:77
本文介绍了如何在输入一个使用c语言具有相同数量1的二进制数的数字后找到第一个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实我无法解决这个问题。请帮帮我..........



十进制数:(23,24,25,26,27,28,29)
二进制数:(10111,11000,11001,11010,11011,11100,11101)

这里同样是23,27,29这个中有4个'1'如果我输入23那么它将显示一个十进制数,它也有四个'1',并且最接近另一个(四个'1')数。

Actually I can't solve this . please help me..........

Decimal Number : (23,24,25,26,27,28,29)
Binary Number of them :(10111,11000,11001,11010,11011,11100,11101)
Here same is 23,27,29 there are four '1' among this 23,27 and 29. If I input 23 then it will show a decimal number which also have four '1' and which is nearest from the other same (four '1') number.

推荐答案

移位和逻辑运算符的组合将帮助您。请参阅 http://msdn.microsoft.com/en-us/library/y0c1cfax.aspx [ ^ ]。
A combination of shift and logical operators will help you. See http://msdn.microsoft.com/en-us/library/y0c1cfax.aspx[^].


这篇关于如何在输入一个使用c语言具有相同数量1的二进制数的数字后找到第一个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆