[問題] Re: 如何換成十進位呢
假設你二進位存在陣列 two 中
int ten = 0;
for(int k = 0; k < n; k++) {
ten = ten*2 + two[k];
}
※ 引述《derange99 (derange)》之銘言:
: CPP
: 請問輸入一二進位的數(ex:10010),要怎麼將他換成十進位?
: (Use the modulus and division operators to pick off the binary number's
: digits one at a time from right to the left)
: 因為才剛學cpp,所以能用簡單的方法最好
: 感激不盡
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 180.217.21.138
→
07/05 13:53, , 1F
07/05 13:53, 1F
→
07/05 16:33, , 2F
07/05 16:33, 2F
→
07/05 17:04, , 3F
07/05 17:04, 3F