for the 2nd one, 我的作业。(俺刚写的,还没调试:)

2)Write a function to print a number in binary form.

void BinaryPrint( long decNumber)
{

long appearanceBinNum = 0L;
long decMultiplier = 1L;
while (decNumber > 0)
{
appearanceBinNum += decMultiplier*( decNumber %2);
decNumber /= 2;
decMultiplier *= 10;
}

cout return;

}

所有跟帖: 

<0 呢? -feicen- 给 feicen 发送悄悄话 (0 bytes) () 05/09/2009 postreply 16:31:33

最好使用>>1和&运算符,不过小数不太清楚 -feicen- 给 feicen 发送悄悄话 (0 bytes) () 05/09/2009 postreply 16:44:49

不过所有数既然都是二进制存储,那么用>> &得到的应该就是他的二进制 -feicen- 给 feicen 发送悄悄话 (39 bytes) () 05/09/2009 postreply 17:19:21

wow! -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (0 bytes) () 05/09/2009 postreply 17:32:26

只是0和1,用内存指针直接memcpy ASCII 码就可以得到string,不用比较 -what124- 给 what124 发送悄悄话 (0 bytes) () 05/11/2009 postreply 05:36:12

那1000000000000000000000行吗? -Windows8- 给 Windows8 发送悄悄话 (0 bytes) () 05/28/2009 postreply 11:12:02

请您先登陆,再发跟帖!