# 題目 * 讀入一個1 – 1000000的數字,判斷該數字是否為某數字的平方數:如果是,則印出該數字為哪個數字的平方數;如果不是,則印出0。 # 思路 運用 *C++* 標準庫對數學的計算。 並且一個小數被化整數後他的平方不會等於自身的平方。 我們可以運用這點來做計算。 # Code ```C++=1 #include <iostream> #include <cmath> int main() { int n; std::cin>>n; std::cout<<(pow((int)sqrt(n),2)==n?sqrt(n):0); } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up