unsigned long sqrt(unsigned long num) { unsigned int x,tmp; //x为所求结果 unsigned int i=0xffffffff; //控制循环的次数 x=num/2; while(i--) { tmp = x; x=(x+num/x)/2; if(x>=tmp) return tmp; } return x; }