编辑代码

#include<iostream>
#include<cmath>
using namespace std;
bool judge1(int num){
    int x = 0;
	int s = num;    // 拷贝一份
	while(s>0){
		x = x*10+s%10;    //反向求和,s%10为取s的个位数,例,123取3
		s = s/10;        // 删除s的个位数,例,123变成12
	}
 
	if(x==n){
		return true;
	}
	else{
		return false;
	}
                        
}
bool judge2(int num){
    double r = sqrt(num);
	int x = r;	// 将小数强制转换为整数 
	
	if(r == x){	// 方法二:(int)r,表示将小数r强制转换为整数 
		return true;
	}else{
		return false;
	}
}
int main(){
    int num = 1;
    while(num < 1000000){
        if (judge1(num) && judge2(num)){
            cout << num << endl;
        }
    }
    
}