📜  如何检查数字的sqrt是否为整数c ++代码示例

📅  最后修改于: 2022-03-11 14:44:50.065000             🧑  作者: Mango

代码示例1
bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
}