作者buganini (霸格尼尼)
看板Programming
标题Re: c++ 求平方 我解不出来
时间Fri Nov 10 07:13:07 2006
※ 引述《[email protected] ( )》之铭言:
: #include<iostream>
: #include<cmath>
: using namespace std;
: void is_square(int num);
: int m;
^^^
: m=sqrt(num);
^^^^^^^^^^^^
sqrt()是return double
parameter也要是double或float
http://www.cplusplus.com/ref/cmath/sqrt.html
: if(m * m == num)
: cout<<"是平方数"<<endl;
: else
: cout<<"不是平方数"<<endl;
: }
: 请问我这样写 语法上哪里有错呢
: 谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.114.218.176
※ 编辑: buganini 来自: 140.114.218.176 (11/10 07:14)