sqrt使用时大多需要要强制类型转化,因为sqrt只支持double和float类型, 可以这样 c=(int) sqrt((double)a*a+b*b);或者c=(int) sqrt((float)a*a+b*b);