Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        4年前关闭。
                                                                                            
                
        
输入两个无符号整数a和b并查找b的最低字节是否正好出现在a中(从任何位置开始)的函数。例如:

    Enter a:53
    Enter b:13
    Binary of b: 00000000 00000000 00000000 00001101
    Binary of a: 00000000 00000000 00000000 00110101
    Yes, lowest byte of b appears in a.


伙计们,这是我的家庭作业,但我不能做到,请帮助我,谢谢您的帮助

最佳答案

以下是一些伪代码,可以帮助您入门:

found = FALSE
for shift = 0 to 24
    if least significant byte of a == least significant byte of b then
        found = TRUE
        break
    endif
    shift a right by 1 bit
endfor


现在,您要做的就是将其转换为C代码。

关于c - 二进制搜索两个无符号整数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29162649/

10-12 00:20