69,335
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include "math.h"
int _tmain(int argc, _TCHAR* argv[])
{
long int i,x,y,z;
for (i=1;i<100000;i++)
{
x=sqrt(i+100); /*x为加上100后开方后的结果*/
y=sqrt(i+268); /*y为再加上168后开方后的结果*/
if(x*x==i+100&&y*y==i+268)/*如果一个数的平方根的平方等于该数,这说明此数是完全平
方数*/
printf("\n%ld\n",i);
}
return 0;
}
-------------- 构建: Debug in 11 ---------------
正在链接 控制台可执行: bin\Debug\11.exe
main.cpp
main.cpp(10) : error C2668: “sqrt”: 对重载函数的调用不明确
D:\CodeBlocksSVN\build\vc\include\math.h(589): 可能是“long double sqrt(long double)”
D:\CodeBlocksSVN\build\vc\include\math.h(541): 或 “float sqrt(float)”
D:\CodeBlocksSVN\build\vc\include\math.h(127): 或 “double sqrt(double)”
尝试匹配参数列表“(long)”时
x = (double)sqrt((double)(i + 100));
y = (double)sqrt((double)(i + 268));