Re: c++ 求平方 我解不出來
※ 引述《jiannrong@kkcity.com.tw ( )》之銘言:
: #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)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 6 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章