public class Main {
public static void main(String[] args) {
for (int i = 0; i<= 256; i++) {
String s = String.valueOf(i * i);
int j=0;
int k= s.length()-1;
while (j<=k){
if (s.charAt(j)==s.charAt(k)){
j++;
k--;
}else break;
}
if (j>k) System.out.println(i);
}
}
} #include<iostream>
using namespace std;
int main(){
for(int i=0;i<=256;i++){
int total=0,temp=i*i;
while(temp>0){
total=total*10+temp%10;
temp/=10;
}
if(total==i*i)
cout<<i<<endl;
}
}
#include<iostream>
#include<cstring>
using namespace std;
int reverse(int n) {
int res = 0;
while(n!=0){
res = n % 10 + res * 10;
n /= 10;
}
return res;
}
int main() {
for (int i = 0; i <= 256; i++) {
if (i*i == reverse(i*i))
cout << i << endl;
}
} #include <iostream>
#include <stdio.h>
using namespace std;
int Reverse(int n){
int reverse=0;
int remain;//余数
while(true){
remain=n%10;
reverse=reverse*10+remain;
n=n/10;
if(n==0){
break;
}
}
return reverse;
}
int main() {
int i;
for(i=0;i<=256;i++){
if(i*i==Reverse(i*i)){
printf("%d\n",i);
}
}
} #include <stdio.h>
int isDuichengnum(int m) {
int remain;
int reverse = 0;
while (m) {
remain = m % 10;
m = m / 10;
reverse = reverse * 10 + remain;
}
return reverse;
}
int main() {
for (int i = 0; i <= 256; ++i) {
if (i * i == isDuichengnum(i * i)) {
printf("%d\n", i);
}
}
return 0;
}
#include <stdio.h>
int reverse(int n) {
int reverse = 0;
while(n) {
int remain = n%10;
n = n/10;
reverse = reverse*10 + remain;
}
return reverse;
}
int main() {
int a, b;
for(int i = 0; i <= 256; i++) {
int x = i * i;
if(x == reverse(x)) printf("%d\n", i);
}
return 0; #include<stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main() {
for(int i=0;i<=256;i++)
{
int s=i*i;
if(s<10){printf("%d\n",i);}
if(s>10&&s<99)
{
int a=s/10;
int b=s%10;
if(a==b){printf("%d\n",i);}
}
if(s>100&&s<999)
{
int a,b;
a=s/100;
b=s%10;
if(a==b){printf("%d\n",i);}
}
if(s>1000&&s<9999)
{
int a,b,c,d;
a=s/1000;
b=(s/100)%10;
c=(s/10)%10;
d=s%10;
if(a==d&&b==c){printf("%d\n",i);}
}
if(s>10000&&s<=65536)
{
int a,b,c,d,e;
a=s/10000;
b=(s/1000)%10;
//c=(s/100)%10;
d=(s/10)%10;
e=s%10;
if(a==e&&b==d){printf("%d\n",i);}
}
}
//system("pause");
return 0;
} #include <iostream>
using namespace std;
bool sym(int n){
int res = 0,temp = n;
while( n != 0){
res = res*10 + n%10;
n /= 10;
}
return temp == res;
}
int main() {
for(int i=0; i<=256; ++i){
if(sym(i*i)) cout << i << endl;
}
return 0;
} #include <iostream>
using namespace std;
int main() {
for(int i=0;i<=256;i++){
int pf=i*i;
if(pf<10){
printf("%d\n",i);
}
else if(pf<100){ //两位数
if(pf/10==pf%10){
printf("%d\n",i);
}
}
else if(pf<1000){ //三位数
if(pf/100==pf%10){
printf("%d\n",i);
}
}
else if(pf<10000){ //四位数
if((pf/1000==pf%10)&&(pf/100%10==pf/10%10)){
printf("%d\n",i);
}
}
else{ //五位数
if((pf/10000==pf%10)&&(pf/1000%10==pf/10%10)){
printf("%d\n",i);
}
}
}
return 0;
}