你的代码不对

[复制链接]
查看11 | 回复1 | 2011-1-16 17:03:24 | 显示全部楼层 |阅读模式
#include
#include
using namespace std;
int main()
{
bool prime;
int m,k,i,n=0;
for(m=101;mc:\users\sun\desktop\1.15\cs\cs\main.cpp(12) : error C2668: 'sqrt' : ambiguous call to overloaded function
1>
e:\program files (x86)\microsoft visual studio 8\vc\include\math.h(581): could be 'long double sqrt(long double)'
1>
e:\program files (x86)\microsoft visual studio 8\vc\include\math.h(533): or 'float sqrt(float)'
1>
e:\program files (x86)\microsoft visual studio 8\vc\include\math.h(128): or 'double sqrt(double)'
1>
while trying to match the argument list '(int)'
1>c:\users\sun\desktop\1.15\cs\cs\main.cpp(12) : fatal error C1903: unable to recover from previous error(s); stopping compilation

回复

使用道具 举报

千问 | 2011-1-16 17:03:24 | 显示全部楼层
那你把#include 改成#include k=int (sqrt(m));改成k=int (sqrt(1.0*m));再加上#include试试。这个和编译器有关,我的编译器是GCC/G++,可以顺利通过,你的我不了解。你可以下载一个dev-cpp试试,这个后台是GCC/G++,对标准支持比较好。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行