错误 2 error C2668: “sqrt”: 对重载函数的调用不明确

原出错代码:
#include "stdio.h" #include "math.h" void main() { int i=1,m,k=1; printf("请输入数字:"); scanf("%d",&m); k=sqrt(m); for(;i<k;i++) { if(m%k==0) break; } if(i>k) { printf("是素数"); } else { printf("不是素数"); } }

解决方法

 k=sqrt((float)m);

猜你喜欢

转载自www.cnblogs.com/zyz322/p/12228305.html