帮我看一看 我的编程哪里错了

来源:百度知道 编辑:UC知道 时间:2024/05/29 03:59:46
#include<stdio.h>
#include<math.h>
void main()
{
int i,m,n;
for(i=100;i<=200;i++)
{
n=sqrt(i);
for(m=2;m<=n;m++)
{
if(i%m==0) break;
else
printf("%d",i);
}
}
printf("\n");
}

它提示
1>------ 已启动生成: 项目: aaa, 配置: Debug Win32 ------
1>正在编译...
1>cc.cpp
1>e:\codes\aaa\aaa\cc.cpp(8) : error C2668: “sqrt”: 对重载函数的调用不明确
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(581): 可能是“long double sqrt(long double)”
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(533): 或 “float sqrt(float)”
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(128): 或 “double sqrt(double)”
1> 试图匹配参数列表“(int)”时
1>生成日志保存在“file://e:\codes&

带的参数不对。
double GetNumber;
long NumberSqrt=sqrt(GetNumber);

尝试一下~

我看错了,不好意思

把i,n换成float或double试试看

sqrt(x);
作用为:求x的平方根;
x可以为int float double等类型;
返回值为double类型;

楼主应该将n 定义为double n;