题解 | #对称平方数1#
对称平方数1
https://www.nowcoder.com/practice/a84d46d5321f4e20931cb725e6c74fad
#include <iostream> #include "stdio.h" bool duichen(int n2) { int ge, shi, bai, qian, wan; ge = n2 % 10; shi = (n2 / 10) % 10; bai = (n2 / 100) % 10; qian = (n2 / 1000) % 10; wan = n2 / 10000; if (n2 < 10) return true; if (n2 > 10 && n2 < 100 && ge == shi) { return true; } if (n2 > 100 && n2 < 1000 && ge == bai) { return true; } if (n2 > 1000 && n2 < 10000 && ge == qian && shi == bai) { return true; } if (n2 > 10000 && n2 < 100000 && ge == wan && shi == qian) { return true; } return false; } int main() { int n, n2; for (n = 0; n <= 256; n++) { n2 = n * n; if (duichen(n2)) printf("%d\n", n); } }