内部错误最为致命!!!(贴一个高精度的除法)
HugeInt HugeInt::operator/(const HugeInt& c)const { HugeInt temp(0); HugeInt temp2(*this); int flag=0; for (int j = 1;j <= 10;j++) { if(flag!=0){ j=1; } flag=0; HugeInt temp1(0); if (temp2 < c) break; if (temp2 < c * pow(10,j) ) { for (int p=1;p <= 9;p++) { if (temp2 < c * pow(10, j - 1) * p ) { temp1 = temp2 - c * pow(10, j - 1)*(p-1); temp2 = temp1; flag=1; temp.integer[29-j + 1] = p - 1; break; } if (temp2 == c * pow(10, j - 1) * p ) { temp.integer[29-j + 1] = p ; return temp; } } j = 1; } if (temp2 == c * pow(10, j) ) { temp.integer[29-j] = j; return temp; } } return temp; }
这个循环真的写的很妙!
按道理来说i++应该是在循环最后运行,但是debug的时候发现在运行下一次循环之后i+1了,所以加了一行控制j的语句
结果交上去还内部错误了
我真的会谢!!!

浙公网安备 33010602011771号