#include<stdio.h>
#include<math.h>
int main(){
int isSquare(int);
int i;
while(scanf("%d",&i)&&i>0){
if(isSquare(i))
printf("%d is square\n",i);
else
printf("%d is not square\n",i);
}
return 0;
}
int isSquare(int n){ //判断是不是完全平方数,是返回1,否返回0
if(sqrt(n) == (int)sqrt(n)){ //double sqrt(double);
return 1;
}
return 0;
}
简单的完全平方和判断
![](https://img-home.csdnimg.cn/images/20240711042549.png)