看板 ck54th310 關於我們 聯絡資訊
※ 引述《suckist (▌▌▌▌▌▌▌▌▌▌▌ꈩ》之銘言: : 用2進位滑移寫乘法.... : 但是還是怪怪的.... : 拜託幫我檢查一下,謝謝.. : #include<iostream> : using namespace std; : : void main(unsigned x, unsigned y, unsigned a) : { : cout << " Enter an integer: "; : cin >> x; : cout << " Enter another integer: "; : cin >> y; : int total; : int i; : i =0; : total = 0; //y = ( y<<1 );//這行去掉 : unsigned b; : : while(y>0) : { : //y = (y>>1);//放到迴圈最後面 : b = ( y & 1 ); : a = x<<i; : i++; : if (b = 1) : { : total = (total + a) ; : } //else //這些可以去掉 //{ //total = total; //} y = (y>>1); : } : : cout<<"The sum is "<<total<<endl; : } 你們?的寫法還真妙呀......^^||| -- ※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw) ◆ From: 140.113.122.25
Eric30:XD 簡太強 推140.113.207.215 05/05
suya:您是鬼怪 推 140.113.122.51 05/05
suckist:謝謝您!簡強人...^^ 推140.113.123.125 05/05
FMZ:太鬼了這真的是中文ㄇ? 推 219.91.54.30 05/05
hellfire:完全被諷刺了>"< 推 140.113.122.25 05/05