一个新手有点小问题 [英] bit fiddling question by a newbie

查看:86
本文介绍了一个新手有点小问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的指导如何处理这个问题。

我甚至不知道从哪里开始。这对我来说似乎有点普遍。非常感谢。


设计一个函数来测试一个字节中的位,然后返回

a)成功或失败,

b)在字节中设置(?==?)的位数(

c)字节中位的位置。

解决方案

< blockquote>好吧,好吧,我会从这开始:


设计一个函数来测试一个字节中的位,它返回

a)成功或失败,



看起来你的老师正在向我索要一个函数原型。这将解决你传递给它的东西,以及你从中返回的东西。然后你可以使用b和c并使用它们来开发你的算法,以找出函数的定义(你如何得到你返回的......)


< blockquote class =post_quotes>
好​​吧,好吧,我会从这开始:


看起来你的老师正在向我索要一个函数原型。这将解决你传递给它的东西,以及你从中返回的东西。然后你可以使用b和c并使用它们来开发你的算法,找出函数的定义需要什么(你如何得到你返回的......)



谢谢sicarie。我很丢失这个。你或其他任何人可以给我支持的例子吗?我不是在想象它。我发现它对我来说有点困难。


再次感谢。

Shulapi


你知道它们的功能 - 它们的表现,它们的作用,它们的设置方式吗?


I need your guidance as to how to approach this question.
I don''t even know where to begin. It seems a bit general for me. Thanks alot.

Devise a function to test bits in a byte, and it returns
a) success or failure,
b) count of bits that are set (?==?) in the byte,
c) position of bit(s) in the byte.

解决方案

Okay, well, I would start with this:

Devise a function to test bits in a byte, and it returns
a) success or failure,

Looks like your teacher is asking for a function prototype to me. That will settle what you are passing to it, and what you are returning from it. Then you can take b and c and use them to develop your algorithm for figuring out what needs to be the definition of the function (how you get what you are returning...)


Okay, well, I would start with this:


Looks like your teacher is asking for a function prototype to me. That will settle what you are passing to it, and what you are returning from it. Then you can take b and c and use them to develop your algorithm for figuring out what needs to be the definition of the function (how you get what you are returning...)

Thanks sicarie. I''m kind of lost on this one. Could you or anyone else give me supporting example(s). I''m not visualizing it. I found it a little bit harder for me.

Thanks again.
Shulapi


Are you aware of functions - how they perform, what they do, how they are set up?


这篇关于一个新手有点小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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