輸出位(最簡單的情形)
#include <iostream>
using namespace std;
void display_bits(unsigned u)
{
int t;
for(t = 128; t >= 1; t /= 2)\
{
if(u&t) cout<<"1 ";
else cout<<"0 ";
}
cout<<endl;
}
int main()
{
display_bits(10);
return 0;
}
posted on 2009-10-07 15:50 Error 閱讀(171) 評論(0) 編輯 收藏 引用 所屬分類: C++

