判断一个数是不是素数的问题,请大神们指教!!!
#include<stdio.h>#include <math.h>
void main()
{int m,i,k;
scanf_s("%d",&m);
k= sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0) break;
if(i>k)printf("%d是素数",m);
else printf("%d是合数",m);
}
出现的问题是:
1>------ Build started: Project: su shu, Configuration: Debug Win32 ------
1>Build started 2012/10/14 15:08:51.
1>InitializeBuildStatus:
1> Touching "Debug\su shu.unsuccessfulbuild".
1>ClCompile:
1> su shu.cpp
1>d:\hello\su shu\su shu\su shu.cpp(7): error C2668: 'sqrt' : ambiguous call to overloaded function
1> d:\program files\vs2010\vc\include\math.h(589): could be 'long double sqrt(long double)'
1> d:\program files\vs2010\vc\include\math.h(541): or 'float sqrt(float)'
1> d:\program files\vs2010\vc\include\math.h(127): or 'double sqrt(double)'
1> while trying to match the argument list '(int)'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.67
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========