我想要分割的兩個int值,但將其劃分後我收到只有一個值是0 以下是我的公式:獲得分割後INT 0值中,
int RH=(A1/M1)*100(where A1=145 and M1=199)
其中RH
值應有72,但我得到0,有人可以幫我嗎?
以下是我的代碼:
int RvalueH,RvalueV,RvalueT;
if((M1!=-1 || M1>0) && (M2!=-1 || M2>0) && (M3>0 || M3!=-1))
{
int RH = (A1/M1);
int RV = A2/M2;
int RT = A3/M3;
RvalueH=RH*100;
RvalueV=100*RV;
RvalueT=100*RT;
}
您認爲'RH'的價值是什麼? (注意它是一個int,整數除法的結果......)145/199是* not * 72. –
但是(145/199)* 100 = 72對於int –
145/172是0 btw – Rusty