for the 2nd one, 我的作業。(俺剛寫的,還沒調試:)

來源: 戲雨飛鷹 2009-05-09 16:20:58 [] [博客] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (362 bytes)
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 << appearanceBinNum;
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

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”