int mySqrt(int x) { double t=1.0; //初始迭代值 double cheak; //误差 double p = 1e-2; //误差上限 do { t = (x / t + t) / 2.0; cheak = t * t - x; } while((cheak >= 0 ? cheak : -cheak) > p); return (int)t; } double myCube(int x) { double t=1.0; double cheak; double p = 1e-5; do { t = (x / pow(t,2) + 2*t) / 3.0; cheak = pow(t,3) - x; } while((cheak >= 0 ? cheak : -cheak) > p); return t; }